checksum works in unix but not win32 os

GujuBoy dirgesh at
Wed Mar 30 03:53:43 CEST 2005

i have the following code...which works fine in UNIX but then i move it
over to WINDOWS XP and check the sum on the same file that i tested on
unix and i get different results.

def checksum(fileobj):
    filedata = array.array('B',
    totbytes = len(filedata)
    result = 0
    def rotate_right(c):
        if c&1: return (c>>1)|0x8000
        else: return c>>1
    for ch in filedata:
        result = (rotate_right(result)+ch) & 0xFFFF
    return result

Unix File = 8683
Win32 = 23662

Please let me know why its acting different in WIN32, also it only does
this on SOME files...out of 50 i tested only 5 it failed on.

More information about the Python-list mailing list