Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Reverse CRC table for Castagnoli polynomial (0x1EDC6F41)
- static const unsigned long crc32c_revTable[16] =
- {
- 0x00000000L, 0x05EC76F1L, 0x0BD8EDE2L, 0x0E349B13L,
- 0x17B1DBC4L, 0x125DAD35L, 0x1C693626L, 0x198540D7L,
- 0x2F63B788L, 0x2A8FC179L, 0x24BB5A6AL, 0x21572C9BL,
- 0x38D26C4CL, 0x3D3E1ABDL, 0x330A81AEL, 0x36E6F75FL
- };
- unsigned long calcReverseCRC32C(unsigned long crc32c,
- const unsigned char* pData,
- unsigned long len)
- {
- while (len--)
- {
- crc32c = (crc32c << 4) ^ crc32c_revTable[crc32c >> 28];
- crc32c = (crc32c << 4) ^ crc32c_revTable[crc32c >> 28];
- crc32c ^= *pData--;
- }
- return crc32c;
- }
- {
- // This array contains test data with 4 bytes CRC appended
- // The result of CRC-32C calculation using this data is zero
- unsigned char test[13] = {0x31, 0x32, 0x33, 0x34,
- 0x35, 0x36, 0x37, 0x38,
- 0x39,
- 0x7c, 0x6d, 0xf9, 0x1c};
- unsigned long expectedResultOfCRC = 0;
- unsigned long init = calcReverseCRC32C(expectedResultOfCRC ,
- &test[12],
- 13);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement