Org.BouncyCastle.Crypto.Digests.Sha1Digest.Reset C# (CSharp) Method

Reset() public method

public Reset ( ) : void
return void
        public override void Reset()
        {
            base.Reset();

            H1 = 0x67452301;
            H2 = 0xefcdab89;
            H3 = 0x98badcfe;
            H4 = 0x10325476;
            H5 = 0xc3d2e1f0;

            xOff = 0;
            Array.Clear(X, 0, X.Length);
        }

Usage Example

コード例 #1
0
ファイル: Utility.cs プロジェクト: jbtule/keyczar-dotnet
        /// <summary>
        /// Hashes each component of the key hash with it's length first.
        /// </summary>
        /// <param name="size">The size.</param>
        /// <param name="components">The components.</param>
        /// <returns></returns>
        public static byte[] HashKeyLengthPrefix(int size, params byte[][] components)
        {
            var sha1 = new Sha1Digest();

            foreach (var data in components)
            {
                byte[] length = GetBytes(data.Length);
                sha1.BlockUpdate(length, 0, length.Length);
                sha1.BlockUpdate(data, 0, data.Length);
            }
            var hash = new byte[sha1.GetDigestSize()];
            sha1.DoFinal(hash, 0);
            sha1.Reset();
            var outBytes = new byte[size];
            Array.Copy(hash, 0, outBytes, 0, outBytes.Length);
            return outBytes;
        }