Skip to content

Instantly share code, notes, and snippets.

@thuhak
Created October 29, 2019 08:43
Show Gist options
  • Save thuhak/0cd0507f1cc8b646332c0cd86088e4d4 to your computer and use it in GitHub Desktop.
Save thuhak/0cd0507f1cc8b646332c0cd86088e4d4 to your computer and use it in GitHub Desktop.
check_md5
from hashlib import md5
from functools import partial
def calc_md5(some_file):
mymd5 = md5()
try:
with open(some_file, 'rb') as f:
data = iter(partial(f.read, 8192), b'')
for d in data:
mymd5.update(d)
return mymd5.hexdigest()
except:
return None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment