1

I have gone through the questions with the same issue but are of no help. I checked my code and it's same as they suggested.

//Create the hash value from the array of bytes.
byte[] KeyHashValue = SHhash.ComputeHash(Encoding.UTF8.GetBytes(key.Length > 0? key : Password));

aesProvider.BlockSize = 128;
aesProvider.KeySize = 256;
aesProvider.IV = App.iv;
aesProvider.Key = KeyHashValue;
aesProvider.Mode = CipherMode.CBC;
aesProvider.Padding = PaddingMode.PKCS7;
//aesProvider.Padding = PaddingMode.None;

// Convert Base64 strings to byte array
byte[] src = System.Convert.FromBase64String(encrypted);

// decryption
using (ICryptoTransform decrypt = aesProvider.CreateDecryptor())
{
    try
    {
        byte[] dest = decrypt.TransformFinalBlock(src, 0, src.Length); ---> Getting crash at this line.
        plain = Encoding.Unicode.GetString(dest);

    }
    catch (Exception exception)
    {
        System.Windows.MessageBox.Show("In catch of decrypt  : " + exception.Message);
    }

}

Can anyone suggest me the required changes? I have also tried to change the padding to None but that didn't work too.

UPDATE : I am using email id as Key here. If I use the small letters it works but if I use any capital in email id, it gives this error.

Heena
  • 2,348
  • 3
  • 32
  • 58

0 Answers0