0

Is it correct behavior that binascii.crc32 outputs different checksum lengths: sometimes 8 digits, sometimes 9 or 10. I use it for an array of bytes: <700 bytes.

The code:

print(binascii.crc32(array_of_bytes))

Results:

3844368964
1383389069
132823901
3963271002
620395401
596927826
706646509
1571319956
243595751
908768330
Mr D
  • 23
  • 5
  • 1
    A 32-bit number can appear as anything *up to* 10 digits in decimal. It could even be a single digit, although that's extremely unlikely here. – jasonharper Sep 17 '20 at 16:36

1 Answers1

0

Yes, it is correct behavior. All of them are 32-bits long. Just some have more zeros in the most significant bits. On average, 23% of them will be nine digits or shorter. 2.3% will be eight digits or shorter.

Mark Adler
  • 101,978
  • 13
  • 118
  • 158