I\'m in a situation where I need to encrypt / decrypt a file of n length securely, ideally using Rijndael, but definitely at 256bit encryption.
I\'ve played around with
The Stream.Read method, returns the number of bytes actually being read from the stream.
You should use this return value as the last parameter in the Write method on the next line.
My code would look like this:
byte[] chunkData = new byte[chunkSize];
var bytesRead = 0;
while ((bytesRead = fsInput.Read(chunkData, 0, chunkSize)) > 0)
{
cryptoStream.Write(chunkData, 0, bytesRead);
}