[Larry Bates] > I'm trying to get the results of binascii.crc32 > to match the results of another utility that produces > 32 bit unsigned CRCs. binascii.crc32 returns > results in the range of -2**31-1 and 2**21-1. Has > anyone ever worked out any "bit twiddling" code to > get a proper unsigned 32 bit result from binascii.crc32?
Just "&" the result with 0xffffffff (a string of 32 1-bits). > Output snip from test on three files: > > binascii.crc32=-1412119273, oldcrc32= 2221277246 > binascii.crc32=-647246320, oldcrc32=73793598 > binascii.crc32=-1391482316, oldcrc32=79075810 Doesn't look like these are using the same CRC algorithms (there are many distinct ways to compute a 32-bit CRC). For example, >>> print -1412119273 & 0xffffffff 2882848023 and that's not equal to 2221277246. Or you're on Windows, and forgot to open the files in binary mode. Or something ;-) -- http://mail.python.org/mailman/listinfo/python-list