예제 #1
0
        private UInt32[] MakeTable(UInt32 polynomial, int offset)
        {
            UInt32[] table = new UInt32[256];

            UInt64 c, x, rem;

            for (int i = table.GetLowerBound(0); i <= table.GetUpperBound(0); i++)
            {
                c   = ((UInt64)i) << offset;
                rem = 0;

                for (int part = 8; --part >= 0;)
                {
                    x   = c >> 56;
                    c <<= 8;

                    rem ^= x;
                    for (int j = 8; --j >= 0;)
                    {
                        rem = (rem & (0x01u)) != 0 ? polynomial ^ (rem >> 1) : (rem >> 1);
                    }
                }

                table[i] = (UInt32)rem;
            }
            return(table);
        }