static public ulong Combine()

in src/AlibabaCloud.OSS.V2/Internal/Crc64.cs [104:157]


        static public ulong Combine(ulong crc1, ulong crc2, long len2)
        {
            // degenerate case.
            if (len2 == 0)
                return crc1;

            int n;
            ulong row;
            ulong[] even = new ulong[GF2_DIM]; // even-power-of-two zeros operator
            ulong[] odd = new ulong[GF2_DIM];  // odd-power-of-two zeros operator

            // put operator for one zero bit in odd
            odd[0] = _poly;      // CRC-64 polynomial

            row = 1;
            for (n = 1; n < GF2_DIM; n++)
            {
                odd[n] = row;
                row <<= 1;
            }

            // put operator for two zero bits in even
            Gf2MatrixSquare(even, odd);

            // put operator for four zero bits in odd
            Gf2MatrixSquare(odd, even);

            // apply len2 zeros to crc1 (first square will put the operator for one
            // zero byte, eight zero bits, in even)
            do
            {
                // apply zeros operator for this bit of len2
                Gf2MatrixSquare(even, odd);
                if ((len2 & 1) == 1)
                    crc1 = Gf2MatrixTimes(even, crc1);
                len2 >>= 1;

                // if no more bits set, then done
                if (len2 == 0)
                    break;

                // another iteration of the loop with odd and even swapped
                Gf2MatrixSquare(odd, even);
                if ((len2 & 1) == 1)
                    crc1 = Gf2MatrixTimes(odd, crc1);
                len2 >>= 1;

                // if no more bits set, then done
            } while (len2 != 0);

            // return combined crc.
            crc1 ^= crc2;
            return crc1;
        }