Example #1
0
        private void Stream_Closing(object sender, EventArgs e)
        {
            if (_pMode != CryptoStreamMode.Write)
            {
                throw new InvalidOperationException();
            }
            CloseNotifyStream closeNotifyStream = (CloseNotifyStream)sender;
            int num1 = checked ((int)(_pPosition % _pTransform.OutputBlockSize));

            if (num1 == 0)
            {
                num1 = 16;
            }
            byte[] buffer = new byte[checked (num1 - 1 + 1)];
            closeNotifyStream.Write(buffer, 0, buffer.Length);
            _pSha.TransformFinalBlock(new byte[0], 0, 0);
            string s     = "";
            int    num2  = 0;
            int    num3  = checked (_pSha.Hash.Length - 1);
            int    index = num2;

            while (index <= num3)
            {
                s += _pSha.Hash[index].ToString("X2");
                checked { ++index; }
            }
            byte[] bytes = Encoding.UTF8.GetBytes(s);
            if (bytes.Length != 64)
            {
                throw new IOException();
            }
            closeNotifyStream.Write(bytes, 0, bytes.Length);
        }