Rijndael AES encryption

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
 
D

David Webb

Casey,

Thanks for the link for the AES encryption. You mentioned in your blog that
you did a .NET CF version with the C DLL thats a bit faster. Do you have a
link to that code? I don't have EVC setup right now to compile that.

Thanks,
Dave
 
C

Creighton Hager

I ported a C++ implementation of Rijndael to C# that works in the .NET
CF. Not sure how fast it is compared to optimized C/C++ versions. It
does CBC and the other modes are just trivial changes. If you like, I
can email you the source code.

Cheers,
Creighton
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top