binascii.crc32 results not matching

Raymond L. Buvel levub137 at wi.rr.com
Sat Dec 10 09:43:52 EST 2005


Tim Peters wrote:
> [Raymond L. Buvel]
> 
>>Check out the unit test in the following.
>>
>>http://sourceforge.net/projects/crcmod/
> 
> 
> Cool!
> 
> 
>>I went to a lot of trouble to get the results to match the results of
>>binascii.crc32.  As you will see, there are a couple of extra operations
>>even after you get the polynomial and bit ordering correct.
> 
> 
> Nevertheless, the purpose of binascii.crc32 is to compute exactly the
> same result as most zip programs give.  All the details (including
> what look to you like "extra operations" ;-)) were specified by RFC
> 1952 (the GZIP file format specification).  As a result,
> binascii.crc32 matches, e.g., the CRCs reported by WinZip on Windows,
> and gives the same results as zlib.crc32 (as implemented by the zlib
> developers).

Since there are probably others following this thread, it should be
pointed out that the specification of those "extra operations" is to
avoid some pathalogical conditions that you can get with a simplistic
CRC operation.  For example, using 0 as the starting value will give a
value of zero for an arbitrary string of zeros.  Consequently, a file
starting with a string of zeros will have the same CRC as one with the
zeros stripped off.  While starting with 0xFFFFFFFF will give a non-zero
value.



More information about the Python-list mailing list