Checksum code
Robin Becker
robin at jessikat.fsnet.co.uk
Tue May 28 04:05:03 EDT 2002
In article <mailman.1022527003.5694.python-list at python.org>,
jepler at unpythonic.net writes
......
>It looks like the following version would "work" in 1.5.2 and 2.2:
> def _add32(x, y):
> return (0L+x+y) & 0xFFFFFFFFl
>the math again becomes math on longs, and the & restricts to 32 bits
>(intermediate results are calculated with more bits and cut down to
>size here)
>
>Jeff
.....
yes I think you're right this works in Python. It's pretty inefficient,
but I suppose we need to use C if efficiency becomes an issue. I tried
_add32 as above and get
>>> PDF_CSUM(data)
2981146554L
>>> hex(2981146554L)
'0xB1B0AFBAL'
>>> _add32(0xB1B0AFBA,-PDF_CSUM(data))
0L
so I suppose all the .ttf things have a common check sum.
--
Robin Becker
More information about the Python-list
mailing list