-
-
[求助]请问谁知道CryptographicException :不正确的数据这个异常怎么解决?有谁遇到过吗?万分感激
-
发表于: 2017-9-6 23:06 3452
-
代码如下:
DESCryptoServiceProvider dESCryptoServiceProvider = new DESCryptoServiceProvider();
dESCryptoServiceProvider.Key = Encoding.UTF8.GetBytes(string_0);
dESCryptoServiceProvider.IV = Encoding.UTF8.GetBytes(string_3);
dESCryptoServiceProvider.Mode = CipherMode.ECB;
using (FileStream fileStream = new FileStream(string_1, FileMode.Open, FileAccess.Read))
{
using (FileStream fileStream2 = new FileStream(string_2, FileMode.Create, FileAccess.Write))
{
ICryptoTransform transform = dESCryptoServiceProvider.CreateDecryptor();
// CryptoStream cryptoStream = new CryptoStream(fileStream2, transform, CryptoStreamMode.Write);
byte[] array = new byte[fileStream.Length];
fileStream.Read(array, 0, array.Length);
// cryptoStream.Write(array, 0, array.Length);
// cryptoStream.Close();
using (CryptoStream encStream = new CryptoStream(fileStream2, transform, CryptoStreamMode.Write))
{
encStream.Write(array, 0, array.Length);
encStream.Close();
}
fileStream.Close();
fileStream2.Close();
}
}
运行到encStream.Close();这里就会出现这个异常,请教大神指点
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课
赞赏
看原图
赞赏
雪币:
留言: