来自评论:
一旦我手动将填充设置为NONE
,问题就消失了
这段代码有什么问题? VS2010确实编译了它,但从VS2010运行时出错,说cs.close()填充无效,有人可以帮忙吗?感谢
public static byte[] Decrypt(byte[] cipherData,byte[] Key, byte[] IV)
{
MemoryStream ms = new MemoryStream();
Rijndael alg = Rijndael.Create();
alg.Key = Key;
alg.IV = IV;
alg.Padding = PaddingMode.PKCS7, ;
CryptoStream cs = new CryptoStream(ms,
alg.CreateDecryptor(), CryptoStreamMode.Write);
cs.Write(cipherData, 0, cipherData.Length);
cs.Close();
byte[] decryptedData = ms.ToArray();
return decryptedData;
答案 0 :(得分:0)
您是否尝试过以下操作?
cs.Write(cipherData, 0, cipherData.Length);
//Add this line:
cs.FlushFinalBlock();
cs.Close();