更新
我想加密一个大文件(例如超过 180 个月)。但我得到了System.OutOfMemoryException
FlushFinalBlock()。
这似乎是一种有价值的方法,因为它“完成”了在我的流的页眉和页脚使用附加字节加密我的数据(也许是填充?)。
有没有办法不出现此错误或使用其他方法?
这是我的代码:
MemoryStream memoryStream = new MemoryStream();
// Define cryptographic stream (always use Write mode for encryption).
CryptoStream cryptoStream = new CryptoStream
(
memoryStream,
encryptor,
CryptoStreamMode.Write
);
// Start encrypting.
cryptoStream.Write(byteArray, 0, byteArray.Length);
// Finish encrypting.
cryptoStream.FlushFinalBlock();