Encrypting is the translation of data into a secret code. Encryption is the most effective way to achieve data security. And for now we will create a program that can encrypt an inputted text.
Now, let's start this Font Dialog tutorial!
1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio: Go to
File, click
New Project, and choose Windows
Application.
2. Next, add one TextBox name
TextBox1 for inputting a text, one label named
lblOutput that will be used for displaying the output, and one Button named
for encrypting the inputted text and will be displayed in the Label. You must design your layout like this:
4. Now put this code in your code module.
Imports System.Security.Cryptography
Imports System.Text
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim encryptMD5 As New MD5CryptoServiceProvider()
Dim encryptedText As Byte()
Dim encoder As New UTF8Encoding()
encryptedText = encryptMD5.ComputeHash(encoder.GetBytes(TextBox1.Text))
lblOuput.Text = Convert.ToBase64String(encryptedText)
End Sub
End Class
Explanation:
We have imported System.Security.Cryptography and System.Text. The
System.Security.Cryptography namespace provides cryptographic services, including secure encoding and decoding of data, as well as many other operations, such as hashing, random number generation, and message authentication. And the
System.Text namespace contains classes that represent ASCII and Unicode character encodings; abstract base classes for converting blocks of characters to and from blocks of bytes; and a helper class that manipulates and formats String objects without creating intermediate instances of String.
We initialized variable
encryptMD5 As New MD5CryptoServiceProvider() to provide encryption or cryptographic services, variable
encryptedText As Byte() to get the Byte of a certain text, and variable
encoder As New UTF8Encoding() for using a Unicode character encodings. Next, the encryptedText gets the byte of the Hash of encryptMD5 and the UTF8Encoding of the TextBox1. Then the output will display at lblOutput that the encryptedText was converted into Base64String.
Output:
Download the source code below and try it! :)
For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below and hire me.
Best Regards,
Engr. Lyndon R. Bermoy
IT Instructor/System Developer/Android Developer
Mobile: 09079373999
Telephone: 826-9296
E-mail:[email protected]
Visit and like my page on Facebook at: Bermz ISware Solutions
Subscribe at my YouTube Channel at: SerBermz