private static void PostProcess(ref UInt32 h, UInt32[] initValues, int dataCount, byte[] remainder) { if (dataCount >= 16) { h = initValues[0].RotateLeft(1) + initValues[1].RotateLeft(7) + initValues[2].RotateLeft(12) + initValues[3].RotateLeft(18); } h += (UInt32) dataCount; if (remainder != null) { // In 4-byte chunks, process all process all full chunks for (int x = 0; x < remainder.Length / 4; ++x) { h += BitConverter.ToUInt32(remainder, x * 4) * _primes32[2]; h = h.RotateLeft(17) * _primes32[3]; } // Process last 4 bytes in 1-byte chunks (only runs if data.Length % 4 != 0) for (int x = remainder.Length - (remainder.Length % 4); x < remainder.Length; ++x) { h += (UInt32) remainder[x] * _primes32[4]; h = h.RotateLeft(11) * _primes32[0]; } } h ^= h >> 15; h *= _primes32[1]; h ^= h >> 13; h *= _primes32[2]; h ^= h >> 16; }
private static void ProcessGroup(ref UInt32 h1, byte[] dataGroup, int position, int length) { for (var x = position; x < position + length; x += 4) { UInt32 k1 = BitConverter.ToUInt32(dataGroup, x); k1 *= c1_32; k1 = k1.RotateLeft(15); k1 *= c2_32; h1 ^= k1; h1 = h1.RotateLeft(13); h1 = (h1 * 5) + 0xe6546b64; } }
private static void Final(ref UInt32 a, ref UInt32 b, ref UInt32 c) { c ^= b; c -= b.RotateLeft(14); a ^= c; a -= c.RotateLeft(11); b ^= a; b -= a.RotateLeft(25); c ^= b; c -= b.RotateLeft(16); a ^= c; a -= c.RotateLeft( 4); b ^= a; b -= a.RotateLeft(14); c ^= b; c -= b.RotateLeft(24); }
private void II(ref UInt32 a, UInt32 b, UInt32 c, UInt32 d, UInt32 x, SS s, UInt32 ac ) { unchecked { #if !XX_inOneInstruction a += I(b, c, d) + x + ac; a = a.RotateLeft((int)s); a += b; #else a = (a += I(b, c, d) + x + ac).RotateLeft((int)s) + b; #endif } }
private static void Mix(ref UInt32 a, ref UInt32 b, ref UInt32 c) { a -= c; a ^= c.RotateLeft( 4); c += b; b -= a; b ^= a.RotateLeft( 6); a += c; c -= b; c ^= b.RotateLeft( 8); b += a; a -= c; a ^= c.RotateLeft(16); c += b; b -= a; b ^= a.RotateLeft(19); a += c; c -= b; c ^= b.RotateLeft( 4); b += a; }