CRC32 on files

Nikolai Kirsebom nikolai.kirsebom at
Fri Jan 4 09:24:43 EST 2002

Script I'm using to generate CRC on set of files:

# Generate CRC32 on file

import zlib
import array
import sys
import os

if __name__ == '__main__':
    if len(sys.argv) < 2:
        print "Usage: python filename filename ..."
    for fn in sys.argv[1:]:
        fileSize = os.stat(fn)[6]
        f = open(fn, "rb")
        v = array.array('B')
            v.fromfile(f, fileSize)
            i = zlib.crc32(v.tostring())
            print "Crc32 of %s is :%d:" % (fn, i)
            print "Not able to read / generate CRC for file :%s:" %


On Fri, 4 Jan 2002 02:03:18 -0500, "Adonis Vargas"
<deltapigz at> wrote:

>how do i run a CRC32 checksum on a file with python? or do i have the
>concept all wrong.
>pardon my ignorance, first time i even touch upon this subject.
>thanks in advance.

More information about the Python-list mailing list