This code snippet has a somewhat common bug. I've seen this bug in all sorts of buffer manipulation code, not just cryptography, so I thought I'd share this. CryptoStream cs = new CryptoStream(myStream, myTransform, CryptoStreamMode.Read); byte[] fromEncrypt