D
David Webb
Hi,
Anyone have any suggestions for implementing Rijndael AES encryption in the
CF?
System.Security.Cryptography.Rijndael is not supported nor is AES available
in the CE crypto library. It has to be AES since it needs to work with an
existing system. It also has to support CipherMode.ECB
The code I use on the deskop is below.
Thanks,
Dave
Public Function EncryptString(ByRef inStr As String, ByVal HashString As
String)
Dim RijndaelObj As New RijndaelManaged()
Dim RijndaelEncObj As ICryptoTransform, MD5Obj As New
MD5CryptoServiceProvider()
Dim HashedString As Byte(), EncryptedData As Byte(), DecryptedData As
Byte()
Dim StringToHash As Byte() = New ASCIIEncoding().GetBytes(HashString)
Dim DataToEncrypt As Byte() = New ASCIIEncoding().GetBytes(inStr)
RijndaelObj.BlockSize = 128
RijndaelObj.KeySize = 128
RijndaelObj.Mode = CipherMode.ECB
RijndaelObj.Padding = PaddingMode.Zeros
RijndaelObj.Key = MD5Obj.ComputeHash(StringToHash)
RijndaelEncObj = RijndaelObj.CreateEncryptor()
EncryptedData = RijndaelEncObj.TransformFinalBlock(DataToEncrypt, 0,
DataToEncrypt.Length)
If EncryptedData.Length > 0 Then EncryptString =
Convert.ToBase64String(EncryptedData)
End Function
Anyone have any suggestions for implementing Rijndael AES encryption in the
CF?
System.Security.Cryptography.Rijndael is not supported nor is AES available
in the CE crypto library. It has to be AES since it needs to work with an
existing system. It also has to support CipherMode.ECB
The code I use on the deskop is below.
Thanks,
Dave
Public Function EncryptString(ByRef inStr As String, ByVal HashString As
String)
Dim RijndaelObj As New RijndaelManaged()
Dim RijndaelEncObj As ICryptoTransform, MD5Obj As New
MD5CryptoServiceProvider()
Dim HashedString As Byte(), EncryptedData As Byte(), DecryptedData As
Byte()
Dim StringToHash As Byte() = New ASCIIEncoding().GetBytes(HashString)
Dim DataToEncrypt As Byte() = New ASCIIEncoding().GetBytes(inStr)
RijndaelObj.BlockSize = 128
RijndaelObj.KeySize = 128
RijndaelObj.Mode = CipherMode.ECB
RijndaelObj.Padding = PaddingMode.Zeros
RijndaelObj.Key = MD5Obj.ComputeHash(StringToHash)
RijndaelEncObj = RijndaelObj.CreateEncryptor()
EncryptedData = RijndaelEncObj.TransformFinalBlock(DataToEncrypt, 0,
DataToEncrypt.Length)
If EncryptedData.Length > 0 Then EncryptString =
Convert.ToBase64String(EncryptedData)
End Function