Encrypting Text using SHA and MD5 Hash Encryption.
This program encrypts the text or the word you type in the textbox to SHA(Secure Has Algorithm) and MD5(Message Digest).
What is Encryption?
“Encryption, the process of scrambling a message or other information so that it cannot be easily read, is one of the most critical parts to the security puzzle. If you have the best firewall, very tight security policies, hardened operating systems, virus scanners, intrusion-detection software, antispyware, and every other computer security angle covered but send your data in raw, plain text, then you simply are not secure.”
Now, we are going to create a program that converts the plain text into scrambled text using the said process of encryption. Let’s begin.
Step 1:
Create a form, add 3 Label, 3 Textbox and 2 Buttons. To make it a multiline textbox just click the arrow and check the Multiline. See the image below .
Step 2:
The first textbox – Textbox1, second – Textbox2, third – Textbox3.
In the name property change the first button – btnEncrypt, second button – btnEncryptMD5
Copy the code
What is Encryption?
“Encryption, the process of scrambling a message or other information so that it cannot be easily read, is one of the most critical parts to the security puzzle. If you have the best firewall, very tight security policies, hardened operating systems, virus scanners, intrusion-detection software, antispyware, and every other computer security angle covered but send your data in raw, plain text, then you simply are not secure.”
Now, we are going to create a program that converts the plain text into scrambled text using the said process of encryption. Let’s begin.
Step 1:
Create a form, add 3 Label, 3 Textbox and 2 Buttons. To make it a multiline textbox just click the arrow and check the Multiline. See the image below .
Step 2:
The first textbox – Textbox1, second – Textbox2, third – Textbox3.
In the name property change the first button – btnEncrypt, second button – btnEncryptMD5
Copy the code
Imports System.TextImports System.Security.CryptographyPublic Class frmEncryptDim MD5 As MD5CryptoServiceProviderDim d As New System.Security.Cryptography.TripleDESCryptoServiceProviderDim h As New System.Security.Cryptography.MD5CryptoServiceProviderPrivate Sub btnEncrypt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEncrypt.ClickTextBox2.Text = SHA512(TextBox1.Text)End SubPrivate Function SHA512(ByVal SourceText As String)Dim a() As Byte = Encoding.UTF8.GetBytes(SourceText)Dim b As Byte()Dim c As New SHA512Managedb = c.ComputeHash(a)Dim d As String = BitConverter.ToString(b)Return dEnd FunctionFunction MD5Hash(ByVal value As String) As Byte()Return MD5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(value))End FunctionPrivate Sub btnEncryptMD5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEncryptMD5.ClickTryd.Key = h.ComputeHash(Encoding.Default.GetBytes(TextBox1.Text))d.Mode = Security.Cryptography.CipherMode.ECBDim encrypt As System.Security.Cryptography.ICryptoTransform = d.CreateEncryptorDim b As Byte() = Encoding.Default.GetBytes(TextBox1.Text)Dim c As String = Convert.ToBase64String(encrypt.TransformFinalBlock(b, 0, b.Length))TextBox3.Text = cCatch ex As ExceptionMsgBox(ex.Message)End TryEnd SubEnd Class
Final Output:
Encrypting Text using SHA and MD5 Hash Encryption.
Reviewed by code-dev
on
10:36 PM
Rating:
No comments: