[ Team LiB ] Previous Section Next Section

CryptoStreammarshal by reference, disposable

System.Security.Cryptography (mscorlib.dll)class
public class CryptoStream : System.IO.Stream {
// Public Constructors
   public CryptoStream(System.IO.Stream stream, ICryptoTransform transform, CryptoStreamMode mode);
// Public Instance Properties
   public override bool CanRead{get;
 // overrides System.IO.Stream
   public override bool CanSeek{get;
 // overrides System.IO.Stream
   public override bool CanWrite{get;
 // overrides System.IO.Stream
   public override long Length{get;
 // overrides System.IO.Stream
   public override long Position{set; get;
 // overrides System.IO.Stream
// Public Instance Methods
   public void Clear(  );
   public override void Close(  );
 // overrides System.IO.Stream
   public override void Flush(  );
 // overrides System.IO.Stream
   public void FlushFinalBlock(  );
   public override int Read(in byte[ ] buffer, int offset,  int count);
// overrides System.IO.Stream
   public override long Seek(long offset, System.IO.SeekOrigin origin);
// overrides System.IO.Stream
   public override void SetLength(long value);
 // overrides System.IO.Stream
   public override void Write(byte[ ] buffer, int offset, int count);
// overrides System.IO.Stream
// Protected Instance Methods
   protected virtual void Dispose(bool disposing);
   protected override void Finalize(  );
 // overrides object
}

The CryptoStream class provides a stream-based model for encrypting and decrypting data using symmetric algorithms. The class constructor accepts an instance of System.IO.Stream, an implementation of the ICryptoTransform interface, and a value from the CryptoStreamMode enumeration.

If the CryptoStreamMode value is Read( ), then data is read from System.IO.Stream and passed to the ICryptoTransform for processing. If the CryptoStreamMode value is Write( ), then data is transformed by the ICryptoTransform implementation before being written to the System.IO.Stream. Implementations of ICryptoTransform can be created using the SymmetricAlgorithm.CreateEncryptor( ) and SymmetricAlgorithm.CreateDecryptor( ) methods.

This class extends System.IO.Stream, and therfore can be used as an argument in constructing a new instance of CryptoStream itself, allowing transformations to be chained together.

Hierarchy

System.Object System.MarshalByRefObject System.IO.Stream(System.IDisposable) CryptoStream

    [ Team LiB ] Previous Section Next Section