Calculate CRC32 correctly with Python
22:01 06 May 2015

I'm trying to calculate/generate the CRC32 hash of some random strings using Python but they do not match the values I generate from online sources. Here is what I'm doing on my PC,

>>> import binascii
>>> binascii.crc32('hello-world')
-1311505829

Another approach,

>>> import zlib
>>> zlib.crc32('hello-world')
-1311505829

The fact that the above results are identical tells me that I'm calling the function correctly. But, if I go to the following online sources,

For the string "hello-world" they all give the same value = b1d4025b

Does anyone know what I need to do, to get matching results?

As I was typing this question it occurred to me that I might need to convert my Python result to hex,

>>> hex(zlib.crc32('hello-world'))
'-0x4e2bfda5'

Unfortunately, that hasn't helped either.

python crc32