Skip to content

Instantly share code, notes, and snippets.

@pjaudiomv
Created September 28, 2022 02:36
Show Gist options
  • Save pjaudiomv/91729e20ce8846ef08a5b322f55a2d48 to your computer and use it in GitHub Desktop.
Save pjaudiomv/91729e20ce8846ef08a5b322f55a2d48 to your computer and use it in GitHub Desktop.
sha256 sum python
import hashlib
def get_hash(file):
'''
Return sha256 hash of file
'''
sha256_hash = hashlib.sha256()
with open(file,"rb") as f:
for byte_block in iter(lambda: f.read(4096),b""):
sha256_hash.update(byte_block)
return sha256_hash.hexdigest()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment