Showing posts with label
Getting exception of Invalid length in decryption from AES Algorithm.
Show all posts
Showing posts with label
Getting exception of Invalid length in decryption from AES Algorithm.
Show all posts
public byte[] Decrypt(byte[] encryptedData, RijndaelManaged rijndaelManaged)
{
byte[] AESKey = new byte[] { };
KeyParameter par = new KeyParameter(AESKey);
// SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
IBufferedCipher cipher = CipherUtilities.GetCipher("AES/ECB/NoPadding");
cipher.Init(false, par);
// Gives me "pad block corrupted" error
byte[] output = new byte[cipher.GetOutputSize(encryptedData.Length)];
int len = cipher.ProcessBytes(encryptedData, 8, encryptedData.Length - 8, output, 0);
cipher.DoFinal(output, len);
// byte[] output = cipher.DoFinal(encryptedData);
return output;
}