python generate sha256 code example
Example 1: python sha256 of file
import hashlib
filename = input("Enter the input file name: ")
sha256_hash = hashlib.sha256()
with open(filename,"rb") as f:
for byte_block in iter(lambda: f.read(4096),b""):
sha256_hash.update(byte_block)
print(sha256_hash.hexdigest())
Example 2: sha 256 python
import hashlib
secret_thing = hashlib.sha256()
secret_thing.update(b"hahahahaahhahaa nobody will guess my secret message")
secret_thing.digest_size
secret_thing.block_size