Skip to content

Instantly share code, notes, and snippets.

@iordic
Created October 11, 2016 00:07
Show Gist options
  • Save iordic/5d5d10d4babef81dcc48788d43390846 to your computer and use it in GitHub Desktop.
Save iordic/5d5d10d4babef81dcc48788d43390846 to your computer and use it in GitHub Desktop.
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import hashlib
def sha1Gen(file):
hash = hashlib.sha1()
with open(file, 'rb') as f:
for chunk in iter(lambda: f.read(4096), ''):
hash.update(chunk)
return hash.hexdigest()
def md5Gen(file):
hash = hashlib.md5()
with open(file, 'rb') as f:
for chunk in iter(lambda: f.read(4096), ''):
hash.update(chunk)
return hash.hexdigest()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment