来自评论:
一旦我手动将填充设置为“无”,问题就消失了
这段代码有什么问题吗? 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;
您尝试过以下方法吗?
cs.Write(cipherData, 0, cipherData.Length);
//Add this line:
cs.FlushFinalBlock();
cs.Close();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)