Last active
January 15, 2021 12:11
-
-
Save simonthompson99/044b5c451325ae74fd1dfc53d6093842 to your computer and use it in GitHub Desktop.
[Generate md5sum of file] Generate MD5 sum for a given file path #python
This file contains hidden or 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
| import hashlib | |
| def md5(fname): | |
| """ | |
| returns the md5 for a filepath | |
| """ | |
| BLOCKSIZE = 65536 | |
| hasher = hashlib.md5() | |
| with open(fname, 'rb') as afile: | |
| buf = afile.read(BLOCKSIZE) | |
| while len(buf) > 0: | |
| hasher.update(buf) | |
| buf = afile.read(BLOCKSIZE) | |
| return hasher.hexdigest() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment