Guest User

Untitled

a guest
Apr 22nd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. If Not String.IsNullOrEmpty(TextBox1.Text) And Not String.IsNullOrEmpty(TextBox2.Text) Then
  2.  
  3. Dim password = TextBox1.Text
  4. Dim key = TextBox2.Text
  5.  
  6. Dim keyGenerator = New Rfc2898DeriveBytes(key, 8)
  7. Dim r = New RijndaelManaged
  8.  
  9. r.Mode = CipherMode.CBC
  10. r.Padding = PaddingMode.Zeros
  11. r.BlockSize = 256
  12. r.KeySize = 256
  13. r.FeedbackSize = 256
  14.  
  15. r.IV = keyGenerator.GetBytes(CType(r.BlockSize / 8, Integer))
  16. r.Key = keyGenerator.GetBytes(CType(r.KeySize / 8, Integer))
  17.  
  18. Dim transform As ICryptoTransform = r.CreateEncryptor()
  19.  
  20. Dim encoded As Byte() = Encoding.ASCII.GetBytes(password)
  21. Dim target As Byte() = transform.TransformFinalBlock(encoded, 0, encoded.Length)
  22.  
  23. TextBox3.Text = Encoding.ASCII.GetString(target)
  24.  
  25. End If
Add Comment
Please, Sign In to add comment