Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The code you posted above worked for me (I had to write some code to create an encrypted string to pass). Compiled and run in VS2012 using .Net Framework 4.</p> <p>The encryption code I used was:</p> <pre><code> private static string EncryptStringAES(string plainText, string password, byte[] salt) { RijndaelManaged aesAlg = null; string cypherText = null; try { // generate the key from the shared secret and the salt Rfc2898DeriveBytes key = new Rfc2898DeriveBytes(password, salt); // Create a RijndaelManaged object // with the specified key and IV. aesAlg = new RijndaelManaged(); aesAlg.Key = key.GetBytes(aesAlg.KeySize / 8); aesAlg.IV = key.GetBytes(aesAlg.BlockSize / 8); // Create an encryptor to perform the stream transform. ICryptoTransform encryptor = aesAlg.CreateEncryptor(aesAlg.Key, aesAlg.IV); // Create the streams used for encryption. byte[] bytes = new UTF8Encoding().GetBytes(plainText); using (MemoryStream msEncrypt = new MemoryStream()) { using (CryptoStream csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write)) { csEncrypt.Write(bytes, 0, bytes.Length); csEncrypt.FlushFinalBlock(); cypherText = Convert.ToBase64String(msEncrypt.ToArray()); } } } finally { // Clear the RijndaelManaged object. if (aesAlg != null) { aesAlg.Clear(); } } return cypherText; } </code></pre> <p>Used the following to make the method calls:</p> <pre><code> 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); </code></pre> <p>Resulting string (Test) contained "This is a test".</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload