UPDATE
I want to encrypt a big file (more than 180 mo for example). But I got a System.OutOfMemoryException
with FlushFinalBlock().
It seems to be a valuable methods cause It "finish" encrypting my data with aditionnal bytes at the header and the footer of my stream (maybe the padding?).
Is there a way to not have this error or use an other method?
here my code:
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();