I’m : a web and mobile developer based in the Manning Valley, Australia.

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:

In the end all of that adds up to this:

    byte[] encryptedData;
    byte[] decryptedData;
    byte[] dataBytes = System.Text.ASCIIEncoding.ASCII.GetBytes("hello");

    RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
    encryptedData = rsa.EncryptValue(dataBytes);

    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!