Skip to content

Instantly share code, notes, and snippets.

@NuarkNoir
Created August 1, 2019 07:29
Show Gist options
  • Save NuarkNoir/4cae43bceb9864e862cdc21550116f0c to your computer and use it in GitHub Desktop.
Save NuarkNoir/4cae43bceb9864e862cdc21550116f0c to your computer and use it in GitHub Desktop.
Get file sha256 checksum
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