I need to encrypt and store uploaded files.
These files would then be decrypted and downloaded via a token/ticken mechanism.
It is important that the files do not reside unencrypted, system admins shouldn’t be able to casually access them.
My problem is the files can be quite large, 10 gigs is about the max file size expected.
The encryption process can take as long as needs be.
However I would like the encryption process to work on the fly – so there is no 10 gig decrypted file, only a chunk of it in memory (I don’t have 10 gigs of ram for this).
Any suggestions how to achieve this?
Most encryption is stream-based, so that shouldn’t be a problem at all – just run the
FileStreamas an input to theCryptoStream, and use that as the source for however you are consuming the data; which could be in-process processing, or could be a destinationFileStream(in which case, justcryptoStream.CopyTo(outputFileStream)should suffice).If I borrow the example from MSDN and edit it to show writing binary:
However,
cStreamcould be used for anyStream-based reading.