Public Function Encrypt(ByVal encryptStr As String, ByVal key As String) As String
Dim keyArray As Byte() = UTF8Encoding.UTF8.GetBytes(key)
Dim toEncryptArray As Byte() = UTF8Encoding.UTF8.GetBytes(encryptStr)
Dim rDel As System.Security.Cryptography.RijndaelManaged = New System.Security.Cryptography.RijndaelManaged()
rDel.Key = keyArray
rDel.Mode = System.Security.Cryptography.CipherMode.ECB
rDel.Padding = System.Security.Cryptography.PaddingMode.PKCS7
Dim cTransform As System.Security.Cryptography.ICryptoTransform = rDel.CreateEncryptor()
Dim resultArray As Byte() = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length)
Return Convert.ToBase64String(resultArray, 0, resultArray.Length)
End Function
Public Function Decrypt(ByVal decryptStr As String, ByVal key As String) As String
Dim keyArray As Byte() = UTF8Encoding.UTF8.GetBytes(key)
Dim toEncryptArray As Byte() = Convert.FromBase64String(decryptStr)
Dim rDel As System.Security.Cryptography.RijndaelManaged = New System.Security.Cryptography.RijndaelManaged()
rDel.Key = keyArray
rDel.Mode = System.Security.Cryptography.CipherMode.ECB
rDel.Padding = System.Security.Cryptography.PaddingMode.PKCS7
Dim cTransform As System.Security.Cryptography.ICryptoTransform = rDel.CreateDecryptor()
Dim resultArray As Byte() = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length)
Return UTF8Encoding.UTF8.GetString(resultArray)
End Function