Skip to content

Instantly share code, notes, and snippets.

@notmyname
Created June 22, 2011 07:54
Show Gist options
  • Save notmyname/1039665 to your computer and use it in GitHub Desktop.
Save notmyname/1039665 to your computer and use it in GitHub Desktop.
md5 a large file
import sys
from hashlib import md5
target = sys.argv[1]
csize = 4096
md5sum = md5()
with open(target, 'rb') as f:
blocks = iter(lambda: f.read(csize), '')
for block in blocks:
md5sum.update(block)
print md5sum.hexdigest()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment