binascii.crc32 results not matching
Fredrik Lundh
fredrik at pythonware.com
Sun Dec 11 13:23:51 EST 2005
I wrote:
> this prints
>
> 0xF032519BL 0xF032519BL
> 0x90E3070AL 0x90E3070AL
>
> no time to sort out the int/long mess for binascii.crc32, but it pro-
> bably needs the same tweaking as PIL (which handles the CRC as
> two 16-bit numbers, to avoid sign hell).
I realized that I used 2.3 for testing. under 2.4, the following snippet
runs without warnings:
import binascii
def test2(text, crc=0):
return hex((binascii.crc32(text, crc^-1)^-1)&0xffffffff)
in other words,
crc = binascii.crc32(text, crc^-1)^-1)&0xffffffff
should give the same result as larry's original CalculateCrc function.
</F>
More information about the Python-list
mailing list