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, 0, encryptedData.Length , output, 0);
cipher.DoFinal(output, len);
// byte[] output = cipher.DoFinal(encryptedData);
return output;
}
{
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, 0, encryptedData.Length , output, 0);
cipher.DoFinal(output, len);
// byte[] output = cipher.DoFinal(encryptedData);
return output;
}
No comments:
Post a Comment