示例#1
0
 /// <summary>将写入对象的数据路由到 <see cref="T:System.Security.Cryptography.TripleDES" /> 加密器以计算消息验证代码 (MAC)。</summary>
 /// <param name="rgbData">输入数据。</param>
 /// <param name="ibStart">字节数组中的偏移量,从该位置开始使用数据。</param>
 /// <param name="cbSize">数组中用作数据的字节数。</param>
 protected override void HashCore(byte[] rgbData, int ibStart, int cbSize)
 {
     if (this.m_encryptor == null)
     {
         this.des.Key     = this.Key;
         this.m_encryptor = this.des.CreateEncryptor();
         this._ts         = new TailStream(this.des.BlockSize / 8);
         this._cs         = new CryptoStream((Stream)this._ts, this.m_encryptor, CryptoStreamMode.Write);
     }
     this._cs.Write(rgbData, ibStart, cbSize);
 }
示例#2
0
 /// <summary>在所有数据写入对象后返回计算所得的消息验证代码 (MAC)。</summary>
 /// <returns>计算所得的 MAC。</returns>
 protected override byte[] HashFinal()
 {
     if (this.m_encryptor == null)
     {
         this.des.Key     = this.Key;
         this.m_encryptor = this.des.CreateEncryptor();
         this._ts         = new TailStream(this.des.BlockSize / 8);
         this._cs         = new CryptoStream((Stream)this._ts, this.m_encryptor, CryptoStreamMode.Write);
     }
     this._cs.FlushFinalBlock();
     return(this._ts.Buffer);
 }
示例#3
0
        //
        // protected methods
        //

        protected override void HashCore(byte[] rgbData, int ibStart, int cbSize)
        {
            // regenerate the TripleDES object before each call to ComputeHash
            if (m_encryptor == null)
            {
                des.Key     = this.Key;
                m_encryptor = des.CreateEncryptor();
                _ts         = new TailStream(des.BlockSize / 8); // 8 bytes
                _cs         = new CryptoStream(_ts, m_encryptor, CryptoStreamMode.Write);
            }

            // Encrypt using 3DES
            _cs.Write(rgbData, ibStart, cbSize);
        }
示例#4
0
        protected override byte[] HashFinal()
        {
            // If Hash has been called on a zero buffer
            if (m_encryptor == null)
            {
                des.Key     = this.Key;
                m_encryptor = des.CreateEncryptor();
                _ts         = new TailStream(des.BlockSize / 8); // 8 bytes
                _cs         = new CryptoStream(_ts, m_encryptor, CryptoStreamMode.Write);
            }

            // Finalize the hashing and return the result
            _cs.FlushFinalBlock();
            return(_ts.Buffer);
        }
示例#5
0
        //  
        // protected methods
        //

        protected override void HashCore(byte[] rgbData, int ibStart, int cbSize) {
            // regenerate the TripleDES object before each call to ComputeHash
            if (m_encryptor == null) {
                des.Key = this.Key;
                m_encryptor = des.CreateEncryptor();
                _ts = new TailStream(des.BlockSize / 8); // 8 bytes
                _cs = new CryptoStream(_ts, m_encryptor, CryptoStreamMode.Write);
            }

            // Encrypt using 3DES
            _cs.Write(rgbData, ibStart, cbSize);
        }
示例#6
0
        protected override byte[] HashFinal() {
            // If Hash has been called on a zero buffer
            if (m_encryptor == null) {
                des.Key = this.Key;
                m_encryptor = des.CreateEncryptor();
                _ts = new TailStream(des.BlockSize / 8); // 8 bytes 
                _cs = new CryptoStream(_ts, m_encryptor, CryptoStreamMode.Write);
            }

            // Finalize the hashing and return the result
            _cs.FlushFinalBlock();
            return _ts.Buffer;
        }
 protected override byte[] HashFinal()
 {
     if (this.m_encryptor == null)
     {
         this.des.Key = this.Key;
         this.m_encryptor = this.des.CreateEncryptor();
         this._ts = new TailStream(this.des.BlockSize / 8);
         this._cs = new CryptoStream(this._ts, this.m_encryptor, CryptoStreamMode.Write);
     }
     this._cs.FlushFinalBlock();
     return this._ts.Buffer;
 }
 protected override void HashCore(byte[] rgbData, int ibStart, int cbSize)
 {
     if (this.m_encryptor == null)
     {
         this.des.Key = this.Key;
         this.m_encryptor = this.des.CreateEncryptor();
         this._ts = new TailStream(this.des.BlockSize / 8);
         this._cs = new CryptoStream(this._ts, this.m_encryptor, CryptoStreamMode.Write);
     }
     this._cs.Write(rgbData, ibStart, cbSize);
 }