Created
August 1, 2019 07:29
-
-
Save NuarkNoir/4cae43bceb9864e862cdc21550116f0c to your computer and use it in GitHub Desktop.
Get file sha256 checksum
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
def sha256sum(filename): | |
h = hashlib.sha256() | |
b = bytearray(128*1024) | |
mv = memoryview(b) | |
with open(filename, 'rb', buffering=0) as f: | |
for n in iter(lambda : f.readinto(mv), 0): | |
h.update(mv[:n]) | |
return h.hexdigest() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment