Last active
December 25, 2022 22:08
-
-
Save jamescherti/47e0cd74505147911b483cee11e256b1 to your computer and use it in GitHub Desktop.
A Python method that returns the SHA512 hash of a file.
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
#!/usr/bin/env python | |
# License: MIT | |
# URL: https://gist.github.com/jamescherti/47e0cd74505147911b483cee11e256b1 | |
import hashlib | |
def sha512sum(filename): | |
"""Return the SHA512 hash of a file.""" | |
sha512 = hashlib.sha512() | |
with open(filename, 'rb') as fhandler: | |
for chunk in iter(lambda: fhandler.read(4096), b''): | |
sha512.update(chunk) | |
return sha512.hexdigest() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment