Skip to content

Instantly share code, notes, and snippets.

@JamesTheBard
Created March 17, 2015 17:07
Show Gist options
  • Save JamesTheBard/911107e86758f2dd3e08 to your computer and use it in GitHub Desktop.
Save JamesTheBard/911107e86758f2dd3e08 to your computer and use it in GitHub Desktop.
Python md5sum quickie
from __future__ import print_function
import hashlib
import sys
def md5Checksum(filePath):
with open(filePath, 'rb') as fh:
m = hashlib.md5()
while True:
data = fh.read(8192)
if not data:
break
m.update(data)
return m.hexdigest()
if __name__ == "__main__":
filepath = sys.argv[1]
hash = md5Checksum(filepath)
print("{0}\t{1}".format(hash, filepath))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment