-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchecksum_ui.py
More file actions
25 lines (21 loc) · 834 Bytes
/
Copy pathchecksum_ui.py
File metadata and controls
25 lines (21 loc) · 834 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# ---------------------------------------------------
# Example code for file checksum calculation
# ---------------------------------------------------
# Includes
import hashlib
# ---------------------------------------------------
# Function to Calculate SHA-256 checksum
def calculate_sha256_checksum(file_path):
sha256 = hashlib.sha256()
with open(file_path, 'rb') as f:
# Read the file in chunks of 4K
for byte_block in iter(lambda: f.read(4096), b""):
sha256.update(byte_block)
return sha256.hexdigest()
# File to calculate checksum for
file_name = input("Filename : ")
file_path = "bitstream/{}".format(file_name)
# Print the SHA-256 checksum
checksum_1 = calculate_sha256_checksum(file_path)
print("Filename [{}]".format(file_path))
print("SHA256 Checksum : {}".format(checksum_1))