Ejemplo n.º 1
0
 internal static byte[] GetHashFinalBlock(byte[] input, int ibStart, int cbSize, ABCDStruct ABCD, long len)
 {
     byte[] array = new byte[64];
     byte[] bytes = BitConverter.GetBytes(len);
     Array.Copy(input, ibStart, array, 0, cbSize);
     array[cbSize] = 128;
     if (cbSize <= 56)
     {
         Array.Copy(bytes, 0, array, 56, 8);
         MD5Util.GetHashBlock(array, ref ABCD, 0);
     }
     else
     {
         MD5Util.GetHashBlock(array, ref ABCD, 0);
         array = new byte[64];
         Array.Copy(bytes, 0, array, 56, 8);
         MD5Util.GetHashBlock(array, ref ABCD, 0);
     }
     byte[] array2 = new byte[16];
     Array.Copy(BitConverter.GetBytes(ABCD.A), 0, array2, 0, 4);
     Array.Copy(BitConverter.GetBytes(ABCD.B), 0, array2, 4, 4);
     Array.Copy(BitConverter.GetBytes(ABCD.C), 0, array2, 8, 4);
     Array.Copy(BitConverter.GetBytes(ABCD.D), 0, array2, 12, 4);
     return(array2);
 }
Ejemplo n.º 2
0
        private static byte[] GetHash(byte[] input)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input", "Unable to calculate hash over null input data");
            }
            ABCDStruct aBCD = default(ABCDStruct);

            aBCD.A = 1732584193u;
            aBCD.B = 4023233417u;
            aBCD.C = 2562383102u;
            aBCD.D = 271733878u;
            int i;

            for (i = 0; i <= input.Length - 64; i += 64)
            {
                MD5Util.GetHashBlock(input, ref aBCD, i);
            }
            return(MD5Util.GetHashFinalBlock(input, i, input.Length - i, aBCD, (long)input.Length * 8L));
        }