Can CRC32(C) ever return to 0?

dtoux picture dtoux · Aug 29, 2014 · Viewed 13.3k times · Source

I'm wondering if CRC32 sum and CRC32C in particular ever return to 0? The simple answer would be "yes" given a large enough data set. However, I was wondering if there is any provisioning in CRC32C standard that would explicitly prevent this from happening.

The use case for this is that I need to be able to check if remote file is empty and all I have is its CRC32C check sum. So, in other words can I infer that if CRC32C is 0 then file is guaranteed to be empty.

If possible, please provide any reference to a standard where this is defined.

Answer

Mark Adler picture Mark Adler · Aug 29, 2014

@Yanek is almost completely correct.

Just for fun, here is a five-character sequence that gives a CRC-32C of zero: DYB|O. Here is a four-byte sequence in hex that gives zero: ab 9b e0 9b. In fact, that is the only four-byte sequence that can do so. There are no three-byte or shorter sequences that will give you zero. That is where @Yanek is not exactly right, in that for three-byte or shorter sequences, zero is not just as likely. The probability of getting a zero is zero in those cases.