コード例 #1
0
        public static byte[] GetHash(byte[] input)
        {
            if (null == input)
            {
                throw new System.ArgumentNullException("input", "Unable to calculate hash over null input data");
            }

            //Intitial values defined in RFC 1321
            ABCDStruct abcd = new ABCDStruct {
                A = 0x67452301, B = 0xefcdab89, C = 0x98badcfe, D = 0x10325476
            };

            //We pass in the input array by block, the final block of data must be handled specialy for padding & length embeding
            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));
        }
コード例 #2
0
ファイル: MD5Managed.cs プロジェクト: hasnain2663/MvvmCross-1
 /// <summary>
 /// When overridden in a derived class, finalizes the hash computation after the last data is processed by the cryptographic stream object.
 /// </summary>
 /// <returns>The computed hash code.</returns>
 protected override byte[] HashFinal()
 {
     base.HashValue = MD5Core.GetHashFinalBlock(_data, 0, _dataSize, _abcd, _totalLength * 8);
     return(base.HashValue);
 }