Skip to content

Instantly share code, notes, and snippets.

@zao
Created February 3, 2014 13:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zao/8783455 to your computer and use it in GitHub Desktop.
Save zao/8783455 to your computer and use it in GitHub Desktop.
Python 2.4 implementation of Adler32 checksum
#!/usr/bin/env python
import sys,zlib
for filename in sys.argv[1:]:
try:
file = open(filename,'rb')
part_sum = 1;
while True:
buf = file.read(1024*128)
n = len(buf)
if n == 0:
break
part_sum = zlib.adler32(buf, part_sum)
print ("%08X %s" % (part_sum & 0xFFFFFFFF, filename))
except IOError, (e):
sys.stderr.write('%s: %s: %s\n' % (sys.argv[0], filename, e))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment