Esempio n. 1
0
        private ulong CreateTableEntry(int index)
        {
            ulong r = (ulong)index;

            if (Parameters.RefIn)
            {
                r = CrcHelper.ReverseBits(r, HashSize);
            }
            else if (HashSize > 8)
            {
                r <<= (HashSize - 8);
            }

            ulong lastBit = (1ul << (HashSize - 1));

            for (int i = 0; i < 8; i++)
            {
                if ((r & lastBit) != 0)
                {
                    r = ((r << 1) ^ Parameters.Poly);
                }
                else
                {
                    r <<= 1;
                }
            }

            if (Parameters.RefIn)
            {
                r = CrcHelper.ReverseBits(r, HashSize);
            }

            return(r & _mask);
        }
Esempio n. 2
0
 public override void Initialize()
 {
     _currentValue = Parameters.RefOut ? CrcHelper.ReverseBits(Parameters.Init, HashSize) : Parameters.Init;
 }