Exemplo n.º 1
0
        public unsafe static void Hash(void *message, ulong length, ulong *hash1, ulong *hash2)
        {
            bool flag = length < 192uL;

            if (flag)
            {
                SpookyHash.Short(message, length, hash1, hash2);
            }
            else
            {
                ulong *      ptr = stackalloc ulong[12];
                ulong        num4;
                ulong        num3;
                ulong        num2;
                ulong        num = num2 = (num3 = (num4 = *hash1));
                ulong        num8;
                ulong        num7;
                ulong        num6;
                ulong        num5 = num6 = (num7 = (num8 = *hash2));
                ulong        num12;
                ulong        num11;
                ulong        num10;
                ulong        num9  = num10 = (num11 = (num12 = 16045690984833335023uL));
                SpookyHash.U u     = new SpookyHash.U((ushort *)message);
                ulong *      ptr2  = u.p64 + length / 96uL * 12uL * 8uL / 8uL;
                bool         flag2 = SpookyHash.AllowUnalignedRead || (u.i & 7uL) == 0uL;
                if (flag2)
                {
                    while (u.p64 < ptr2)
                    {
                        SpookyHash.Mix(u.p64, ref num2, ref num6, ref num10, ref num, ref num5, ref num9, ref num3, ref num7, ref num11, ref num4, ref num8, ref num12);
                        u.p64 += (IntPtr)12 * 8;
                    }
                }
                else
                {
                    while (u.p64 < ptr2)
                    {
                        UnsafeUtility.MemCpy((void *)ptr, (void *)u.p64, 96L);
                        SpookyHash.Mix(ptr, ref num2, ref num6, ref num10, ref num, ref num5, ref num9, ref num3, ref num7, ref num11, ref num4, ref num8, ref num12);
                        u.p64 += (IntPtr)12 * 8;
                    }
                }
                ulong num13 = length - (ulong)((long)((byte *)ptr2 - (byte *)message));
                UnsafeUtility.MemCpy((void *)ptr, (void *)ptr2, (long)num13);
                SpookyHash.memset((void *)(ptr + num13 / 8uL), 0, 96uL - num13);
                ((byte *)ptr)[95] = (byte)num13;
                SpookyHash.End(ptr, ref num2, ref num6, ref num10, ref num, ref num5, ref num9, ref num3, ref num7, ref num11, ref num4, ref num8, ref num12);
                *hash1 = num2;
                *hash2 = num6;
            }
        }
Exemplo n.º 2
0
        private unsafe static void Short(void *message, ulong length, ulong *hash1, ulong *hash2)
        {
            ulong *ptr = stackalloc ulong[24];

            SpookyHash.U u    = new SpookyHash.U((ushort *)message);
            bool         flag = !SpookyHash.AllowUnalignedRead && (u.i & 7uL) > 0uL;

            if (flag)
            {
                UnsafeUtility.MemCpy((void *)ptr, message, (long)length);
                u.p64 = ptr;
            }
            ulong num   = length % 32uL;
            ulong num2  = *hash1;
            ulong num3  = *hash2;
            ulong num4  = 16045690984833335023uL;
            ulong num5  = 16045690984833335023uL;
            bool  flag2 = length > 15uL;

            if (flag2)
            {
                ulong *ptr2 = u.p64 + length / 32uL * 4uL * 8uL / 8uL;
                while (u.p64 < ptr2)
                {
                    num4 += *u.p64;
                    num5 += u.p64[1];
                    SpookyHash.ShortMix(ref num2, ref num3, ref num4, ref num5);
                    num2  += u.p64[2];
                    num3  += u.p64[3];
                    u.p64 += (IntPtr)4 * 8;
                }
                bool flag3 = num >= 16uL;
                if (flag3)
                {
                    num4 += *u.p64;
                    num5 += u.p64[1];
                    SpookyHash.ShortMix(ref num2, ref num3, ref num4, ref num5);
                    u.p64 += (IntPtr)2 * 8;
                    num   -= 16uL;
                }
            }
            num5 += length << 56;
            ulong num6     = num;
            ulong num7     = num6;
            ulong expr_156 = num7;

            if (expr_156 <= 15uL)
            {
                switch ((uint)expr_156)
                {
                case 0u:
                    num4 += 16045690984833335023uL;
                    num5 += 16045690984833335023uL;
                    goto IL_2F9;

                case 1u:
                    goto IL_2CC;

                case 2u:
                    goto IL_2B9;

                case 3u:
                    num4 += (ulong)u.p8[2] << 16;
                    goto IL_2B9;

                case 4u:
                    goto IL_296;

                case 5u:
                    goto IL_282;

                case 6u:
                    goto IL_26E;

                case 7u:
                    num4 += (ulong)u.p8[6] << 48;
                    goto IL_26E;

                case 8u:
                    goto IL_249;

                case 9u:
                    goto IL_238;

                case 10u:
                    goto IL_224;

                case 11u:
                    num5 += (ulong)u.p8[10] << 16;
                    goto IL_224;

                case 12u:
                    goto IL_1EC;

                case 13u:
                    goto IL_1D7;

                case 14u:
                    break;

                case 15u:
                    num5 += (ulong)u.p8[14] << 48;
                    break;

                default:
                    goto IL_2F9;
                }
                num5 += (ulong)u.p8[13] << 40;
IL_1D7:
                num5 += (ulong)u.p8[12] << 32;
IL_1EC:
                num5 += (ulong)u.p32[2];
                num4 += *u.p64;
                goto IL_2F9;
IL_224:
                num5 += (ulong)u.p8[9] << 8;
IL_238:
                num5 += (ulong)u.p8[8];
IL_249:
                num4 += *u.p64;
                goto IL_2F9;
IL_26E:
                num4 += (ulong)u.p8[5] << 40;
IL_282:
                num4 += (ulong)u.p8[4] << 32;
IL_296:
                num4 += (ulong)(*u.p32);
                goto IL_2F9;
IL_2B9:
                num4 += (ulong)u.p8[1] << 8;
IL_2CC:
                num4 += (ulong)(*u.p8);
            }
IL_2F9:
            SpookyHash.ShortEnd(ref num2, ref num3, ref num4, ref num5);
            *hash1 = num2;
            *hash2 = num3;
        }