OpenNETCF Encryption
Got encryption working in .NETCF thanks to the help of the OpenNETCF guys. This post is really meant for my own reference so that I can list the sites that had the info I needed:
- The OpenNETCF.Security.Cryptography works almost the same as the real .NET one
- MSDN site detailing System.Security.Cryptography
- Tiny Encryption Algorithm showing me how to convert Bytes< ->String :-)
In the end all of that adds up to this:
byte[] encryptedData;
byte[] decryptedData;
byte[] dataBytes = System.Text.ASCIIEncoding.ASCII.GetBytes("hello");
//Encrypt
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
encryptedData = rsa.EncryptValue(dataBytes);
//Decrypt
decryptedData = rsa.DecryptValue(encryptedData);
MessageBox.Show("Encrypted Data : " + System.Text.ASCIIEncoding.ASCII.GetString(encryptedData, 0, encryptedData.Length));
MessageBox.Show("Decrypted Data : " + System.Text.ASCIIEncoding.ASCII.GetString(decryptedData, 0, decryptedData.Length));
which encrypts the string "Hello" and then decrypts it again!