Last active
October 15, 2021 07:57
-
-
Save kofemann/2303046 to your computer and use it in GitHub Desktop.
A script to calculate adler32 checksum of given files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
'''A script to calculate adler32 checksum of given files''' | |
BLOCKSIZE=256*1024*1024 | |
import sys | |
from zlib import adler32 | |
for fname in sys.argv[1:]: | |
asum = 1 | |
with open(fname,"rb") as f: | |
while True: | |
data = f.read(BLOCKSIZE) | |
if not data: | |
break | |
asum = adler32(data, asum) | |
if asum < 0: | |
asum += 2**32 | |
print(hex(asum)[2:10].zfill(8).lower(), fname) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
for python3.8