private static void PostProcess(ref UInt32 h, UInt32[] initValues, ulong 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;
        }
Example #2
0
        //______________________________________________________________________
        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
            }
        }
Example #3
0
        public void RotationLeft(UInt32 original, Int32 amount, UInt32 expected)
        {
            UInt32 rotated = original.RotateLeft(amount);

            Assert.Equal(expected, rotated);
        }