The code that you posted above worked for me (I had to write code to create an encrypted string for transmission). Compiled and launched in VS2012 using .Net Framework 4.
The encryption code I used was:
private static string EncryptStringAES(string plainText, string password, byte[] salt) { RijndaelManaged aesAlg = null; string cypherText = null; try {
To invoke method calls, do the following:
byte[] salt = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 }; string test = DecryptStringAES(EncryptStringAES("This is a test", "Test", salt), "Test", salt);
The resulting string (Test) contains "This is a test."
Kevin source share