I would like to be able to encrypt / decrypt data as it streams to / from disk. I know that I can write my own Stream and implement encryption there, but I would not risk doing it wrong. Is there a library that works similarly to the following code?
byte[] encryptionKey = ; byte[] initVector = ; var fileStream = new FileStream(filePath, FileMode.CreateNew, FileAccess.Write); var encryptionStream = new AesEncryptionStream(fileStream, initVector, encryptionKey); var gzStream = new GZipStream(encryptionStream, CompressionMode.Compress); var writer = new BinaryWriter(gzStream);
source share