Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can CRC32(C) ever return to 0?

Tags:

crc

crc32

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.

like image 528
dtoux Avatar asked Aug 29 '14 17:08

dtoux


People also ask

Can a CRC32 be reversed?

A CRC32 is only reversible if the original string is 4 bytes or less.

What does CRC32 return?

Return type The CRC32 function returns an 8-character string that is a text representation of the hexadecimal value of a 32-bit binary sequence.

Is CRC32 a crypto?

crc32 (crc stands for cyclic redundancy check) function is not a crypto function and is meant to generate a hash that will be used to check the integrity of a file (mostly to determine if it was corrupted during download).


3 Answers

@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 one to three-byte sequences that will give you zero. That is where @Yanek is not exactly right, in that for one, two, or three-byte sequences, zero is not just as likely. The probability of getting a zero is zero in those cases.

like image 93
Mark Adler Avatar answered Sep 28 '22 18:09

Mark Adler


A zero is as likely as any other value of a CRC32 checksum. A CRC is essentially the remainder of dividing the entire input (taken as one large binary number) by a pre-selected value. If the input happens to be divisible by that value, the remainder, and thus the CRC, is zero.

like image 33
Yanek Martinson Avatar answered Sep 28 '22 20:09

Yanek Martinson


How about this, not a 32-bit CRC, though:

1011 | 110011001010.000
       1011
       ----
        1111
        1011
        ----
         1001
         1011
         ----
           1000
           1011
           ----
             1110
             1011
             ----
              1011
              1011
              ----
                  0000 (...)
                  1011
                  ----
                  1011
                  1011
                  ----
                  0000

Or:

1100 | 11001010.000
       1100
       ----
           1010
           1100
           ----
            1100
            1100
            ----
            (...) 0
like image 43
Sparky Avatar answered Sep 28 '22 18:09

Sparky