Mono Class Library: System.Security.Cryptography Namespace

System.Security.Cryptography.CryptoStream Class

A cryptographic stream class using transforms that can be chained on other streams. [Edit]

See Also: CryptoStream Members

System.Object
     System.MarshalByRefObject
          System.IO.Stream
               System.Security.Cryptography.CryptoStream

[System.Runtime.InteropServices.ComVisible(true)]
public class CryptoStream : System.IO.Stream

Remarks

Multiple CryptoStream can be chained to do multiple cryptographic operations using a single Read or Write operation.

C# Example
// we will be writing encrypted data to this file
FileStream fs = new File.OpenWrite ("data");

Rijndael aes = Rijndael.Create ();
CryptoStream cse = new CryptoStream (fs, aes.CreateEncryptor (), CryptoStreamMode.Write);

SHA1 hash = SHA1.Create ();
CryptoStream csh = new CryptoStream (cse, hash, CryptoStreamMode.Write);

byte[] data = Encoding.UTF8.GetBytes ("http://www.go-mono.com/");

// the data will first be hashed (csh), then encrypted (cse) and finally written to a file (fs)
csh.Write (data, 0, data.Length);
csh.FlushFinalBlock ();

// then we can display the hash (e.g. send it out-of-band)
byte[] hash = hash.Hash;
Console.WriteLine ("SHA1: {0}", BitConverter.ToString (hash));
  
[Edit]

Requirements

Namespace: System.Security.Cryptography
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0