cryptostream

Seekable alternative to .NET's CryptoStream?

Does anybody know a seekable alternative to .NET's CryptoStream? It is OK if the alternative supports Seek only in "read" mode or if it is limited to e.g. AES256. ...

C# CryptoStream result not as expected

I'm trying to understand why the following code results in the encrypted byte array being 16 bytes if plainText is 8 bytes in length. I expected the result to also be 8 bytes in length? private static byte[] encrypt(byte[] key, byte[] plainText) { try { using (MemoryStream ms = new MemoryStream()) { D...

Two CryptoStreams associated with one file in C#

I would like to create a file "myFile" that encrypts the first part using a certain key, and the last part using a certain key. So far I have something like this: cs1 = new CryptoStream(myFile, symmetricKey1.CreateEncryptor(key1, key1IV), CryptoStreamMode.Write); cs2 = new CryptoStream(myFile, symmetricKey2.CreateEncryptor(key2, key2I...

CryptoStream.Close() fails when the disk is full

I am using a CryptoStream for writing encrypted audio data to the file (underlying stream is FileStream). When I try to call CryptoStream.Close() over the full disk, I get an exception. I know that this is because CryptoStream.Close() invokes FlushFinalBlock() during disposing. As a result I get the corrupted data in my encrypted file an...