I had some contact with the CRC-16 checksum in the past and was accustomed to verifying it by recalculating the CRC-16 checksum over the file I want to verify, plus the 2 bytes of the CRC-16 itself. If the result was zero, then the file integrity was valid, otherwise not.
This can be coded very efficiently like with the following pseudo-C:
if (recalculated_crc16_checksum != 0)
// Error: file integrity is corrupt
else
// Success: file integrity is valid
I recently wanted to use the CRC-32 checksum for a file integrity check and tried to verify it the same way, but it seems like this "Compare-Against-Zero-Trick" is not possible here?!
For example if I use the 32-Bit value 0xDEADBEEF on the CRC online calculator:
CRC-16-Modbus(0xDEADBEEF) = 0xC19B
(Same input value but with appended checksum 0xC19B in reversed byte ordering)
CRC-16-Modbus(0xDEADBEEF9BC1) = 0x0000
But:
CRC-32(0xDEADBEEF) = 0x7C9CA35A
(I tried both: big and little endian byte ordering for the appended checksum)
CRC-32(0xDEADBEEF7C9CA35A) = 0x01F92292 != 0x00000000
CRC-32(0xDEADBEEF5AA39C7C) = 0x2144DF1C != 0x00000000
Can someone please explain me, why this "Compare-Against-Zero-Trick" does not work for CRC-32?