Hello everybody,
I'm using these functions in order to Encrypt and Decrypt a text with AES, 128 bit key size.
It seems works fine in encryption but in decryption I've got this error message:
Padding is invalid and cannot be removed.
My Encryption Algorithm:
public static string EncryptAES(string Text)
{
AesCryptoServiceProvider aes = new AesCryptoServiceProvider();
aes.IV = Encoding.UTF8.GetBytes(AesIV128);
aes.Key = Encoding.UTF8.GetBytes(AesKey128);
aes.Mode = CipherMode.CBC;
aes.Padding = PaddingMode.PKCS7;
byte[] src = Encoding.Unicode.GetBytes(Text);
using (ICryptoTransform encrypt = aes.CreateEncryptor())
{
byte[] destin = encrypt.TransformFinalBlock(src, 0, src.Length);
return Convert.ToBase64String(destin);
}
}
My Decryption Functi ...
Go to the complete details ...