Note that there are some explanatory texts on larger screens.

plurals
  1. PODecryption returns 16 bytes instead of 32, why?
    primarykey
    data
    text
    <p>I have the following decryption method that seems to work fine except it is only returning 16 bytes instead of 32 it should I've stared at it too long and can't figure out what I've done wrong. I'm hoping a different set of eyes will help. Thanks.</p> <pre><code>private string Decrypt(string dataToDecrypt, string password, string salt) { //Generate a Key based on a Password, Salt and HMACSHA1 pseudo-random number generator Rfc2898DeriveBytes rfc2898 = new Rfc2898DeriveBytes(password, Encoding.UTF8.GetBytes(salt)); //Create AES algorithm with 256 bit key and 128-bit block size using (var aes = new AesManaged()) { // These two values are hard coded in Silverlight //aes.Mode = CipherMode.CBC; //aes.Padding = PaddingMode.PKCS7; aes.Key = rfc2898.GetBytes(aes.KeySize / 8); aes.IV = rfc2898.GetBytes(aes.BlockSize / 8); //Create Memory and Crypto Streams using (var memoryStream = new MemoryStream()) { using (var cryptoStream = new CryptoStream(memoryStream, aes.CreateDecryptor(), CryptoStreamMode.Write)) { //Decrypt Data byte[] data = Convert.FromBase64String(dataToDecrypt); cryptoStream.Write(data, 0, data.Length); // cryptoStream.FlushFinalBlock(); //Return Decrypted String byte[] decryptBytes = memoryStream.ToArray(); string decrypted = Encoding.UTF8.GetString(decryptBytes, 0, decryptBytes.Length); return decrypted; } // using (cryptoStream = new CryptoStream(memoryStream, aes.CreateDecryptor(), CryptoStreamMode.Write)) } // using (memoryStream = new MemoryStream()) } // using (aes = new AesManaged()) } // string Decrypt(string dataToDecrypt, string password, string salt) </code></pre>
    singulars
    1. This table or related slice is empty.
    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. 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