Last active
March 6, 2018 11:47
-
-
Save MerleLiuKun/82bf3c2a1addebef7b8f49448504d92b to your computer and use it in GitHub Desktop.
python encrypt large file with md5
This file contains 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
def md5_for_file(path): | |
path = path.encode('utf-8') | |
md = hashlib.md5() | |
block_size = 128 * md.block_size | |
with open(path, 'rb') as f: | |
for chunk in iter(lambda: f.read(block_size), b''): | |
md.update(chunk) | |
return md.hexdigest() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment