我得到了这个(我也试过 crStream.CopyTo(ms)):
var cryptic = new DESCryptoServiceProvider();
cryptic.Key = ASCIIEncoding.ASCII.GetBytes(passKey);
cryptic.IV = ASCIIEncoding.ASCII.GetBytes(passKey);
Stream crStream = new CryptoStream(data, cryptic.CreateEncryptor(), CryptoStreamMode.Write);
Stream ms = new MemoryStream();
var buffer = new byte[0x10000];
int n;
while ((n = crStream.Read(buffer, 0, buffer.Length)) != 0) // Exception occurs here
ms.Write(buffer, 0, n);
crStream.Close();
Data = Stream 并包含一个二进制序列化类
当我运行它时出现以下异常:“流不支持阅读。”
我想要完成的只是加密来自流的数据。所以我有一个传入流,我想加密该数据并将其放入内存流中。然后将其压缩并保存到文件中。