Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  Dim DES As New System.Security.Cryptography.TripleDESCryptoServiceProvider
  2.     Dim Hash As New System.Security.Cryptography.MD5CryptoServiceProvider
  3.  
  4.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  5.         Try
  6.             DES.Key = Hash.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(TextBox1.Text))
  7.             DES.Mode = Security.Cryptography.CipherMode.ECB
  8.             Dim DESEncrypter As System.Security.Cryptography.ICryptoTransform = DES.CreateEncryptor
  9.             Dim Buffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(TextBox2.Text)
  10.             TextBox2.Text = Convert.ToBase64String(DESEncrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
  11.         Catch ex As Exception
  12.             MessageBox.Show("The following error(s) have occurred: " & ex.Message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
  13.         End Try
  14.     End Sub
  15.  
  16.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  17.         Try
  18.             DES.Key = Hash.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(TextBox1.Text))
  19.             DES.Mode = Security.Cryptography.CipherMode.ECB
  20.             Dim DESDecrypter As System.Security.Cryptography.ICryptoTransform = DES.CreateDecryptor
  21.             Dim Buffer As Byte() = Convert.FromBase64String(TextBox2.Text)
  22.             TextBox2.Text = System.Text.ASCIIEncoding.ASCII.GetString(DESDecrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
  23.         Catch ex As Exception
  24.             MessageBox.Show("The following error(s) have occurred: " & ex.Message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
  25.         End Try
  26.     End Sub
  27. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement