1# Python program to find SHA256 hash string of a file
2import hashlib
3
4filename = input("Enter the input file name: ")
5sha256_hash = hashlib.sha256()
6with open(filename,"rb") as f:
7 # Read and update hash string value in blocks of 4K
8 for byte_block in iter(lambda: f.read(4096),b""):
9 sha256_hash.update(byte_block)
10 print(sha256_hash.hexdigest())
11