//
        // Overrides
        //
        protected override Stream CreateCryptoStream(Stream stream, AlgorithmKey key)
        {
            SymmetricAlgorithm algo = AlgorithmProvider.Create(this.Algorithm);

             ICryptoTransform transform = algo.CreateDecryptor(key.Key, key.IV);

             //
             // CryptoStream is not seekable, and BizTalk doesn't like that
             // We'll get a "Stream does not support seeking." error
             // at runtime. So we decrypt into an in-memory buffer
             // and then give BizTalk that instead.
             //

             Stream cryptoStream = new CryptoStream(stream, transform, CryptoStreamMode.Read);
             using ( cryptoStream ) {
            MemoryStream memStream = new MemoryStream();
            byte[] buffer = new byte[1024 * 64];
            int bytes = 0;
            do {
               bytes = cryptoStream.Read(buffer, 0, buffer.Length);
               memStream.Write(buffer, 0, bytes);
            } while ( bytes > 0 );
            memStream.Position = 0;
            return memStream;
             }
        }
        //
        // Overrides
        //
        protected override Stream CreateCryptoStream(Stream stream, AlgorithmKey key)
        {
            SymmetricAlgorithm algo = AlgorithmProvider.Create(this.Algorithm);

             ICryptoTransform transform = algo.CreateEncryptor(key.Key, key.IV);

             return new CryptoStream(stream, transform, CryptoStreamMode.Read);
        }
 //
 // Overridable Methods
 //
 /// <summary>
 /// Creates the crypto stream used to encrypt/decrypt the message
 /// </summary>
 /// <param name="stream"></param>
 /// <param name="key"></param>
 /// <returns></returns>
 protected abstract Stream CreateCryptoStream(Stream stream, AlgorithmKey key);