Skip to content

Instantly share code, notes, and snippets.

@vladimirgamalyan
Created February 12, 2024 05:06
Show Gist options
  • Save vladimirgamalyan/170c168f1932cb935afe8ffe9c28e914 to your computer and use it in GitHub Desktop.
Save vladimirgamalyan/170c168f1932cb935afe8ffe9c28e914 to your computer and use it in GitHub Desktop.
Python SHA sample
import hashlib
def sha256sum(filename):
with open(filename, 'rb', buffering=0) as f:
return hashlib.file_digest(f, 'sha256').hexdigest()
print(sha256sum('foo.bar'))
# sample output:
# E95ECA399DFE95500C4DE569EFC4CC77B75E2B66A864D467DF37733EC06A0FF2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment