GetHashFinalBlock() static private method

static private GetHashFinalBlock ( byte input, int ibStart, int cbSize, ABCDStruct ABCD, System.Int64 len ) : byte[]
input byte
ibStart int
cbSize int
ABCD ABCDStruct
len System.Int64
return byte[]
Esempio n. 1
0
        /// <summary>
        /// Return an MD5 hash for the provided parameters
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public static byte[] GetHash(byte[] input)
        {
            if (null == input)
            {
                throw new System.ArgumentNullException("input", "Unable to calculate hash over null input data");
            }

            //Initial values defined in RFC 1321
            ABCDStruct abcd = new ABCDStruct();

            abcd.A = 0x67452301;
            abcd.B = 0xefcdab89;
            abcd.C = 0x98badcfe;
            abcd.D = 0x10325476;

            //We pass in the input array by block, the final block of data must be handled specially for padding & length embedding
            int startIndex = 0;

            while (startIndex <= input.Length - 64)
            {
                MD5Core.GetHashBlock(input, ref abcd, startIndex);
                startIndex += 64;
            }
            // The final data block.
            return(MD5Core.GetHashFinalBlock(input, startIndex, input.Length - startIndex, abcd, (Int64)input.Length * 8));
        }
Esempio n. 2
0
 /// <summary>
 /// Get the final hash
 /// </summary>
 /// <returns></returns>
 protected override byte[] HashFinal()
 {
     base.HashValue = MD5Core.GetHashFinalBlock(_data, 0, _dataSize, _abcd, _totalLength * 8);
     return(base.HashValue);
 }