Guest User

RC2 Encryption Source

a guest
Apr 7th, 2011
2,105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.09 KB | None | 0 0
  1. Public Function RC2Encrypt(ByVal strInput As String, ByVal strPassword As String) As String
  2.   Dim RC2 As New System.Security.Cryptography.RC2CryptoServiceProvider
  3.   Dim HashRC2 As New System.Security.Cryptography.MD5CryptoServiceProvider
  4.   Dim strEncrypted As String = ""
  5.   Try
  6.     Dim Hash() As Byte = HashRC2.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(strPassword))
  7.  
  8.     RC2.Key = Hash
  9.     RC2.Mode = Security.Cryptography.CipherMode.ECB
  10.     Dim DESEncrypter As System.Security.Cryptography.ICryptoTransform = RC2.CreateEncryptor
  11.     Dim Buffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(strInput)
  12.     strEncrypted = Convert.ToBase64String(DESEncrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
  13.     Return strEncrypted
  14.   Catch ex As Exception
  15.   End Try
  16.     End Function
  17.  
  18.     Public Function RC2Decrypt(ByVal strInput As String, ByVal strPassword As String) As String
  19.   Dim RC2 As New System.Security.Cryptography.RC2CryptoServiceProvider
  20.   Dim HashRC2 As New System.Security.Cryptography.MD5CryptoServiceProvider
  21.   Dim strDecrypted As String = ""
  22.   Try
  23.     Dim Ha
Advertisement
Add Comment
Please, Sign In to add comment