.net 加密错误:填充无效,无法移除

今天用System.Security.Cryptography加密。使用了AesManaged,报错:填充无效,无法移除。分析是解密失败,密文损坏,或者KEY,IV不正确。

using (AesManaged aesAlg = new AesManaged())
{
    aesAlg.Key = Encoding.Unicode.GetBytes("password");
    aesAlg.IV = aesAlg.Key;

     using (ICryptoTransform decryptor = aesAlg.CreateDecryptor())
                {
                    return decryptor.TransformFinalBlock(cipherBytes, 0, cipherBytes.Length);
                }

 }

转载于:https://www.cnblogs.com/bushuosx/p/3905668.html

你可能感兴趣的:(.net 加密错误:填充无效,无法移除)