Generate file hash id based on its content using Python

import hashlib

def generate_file_hash(file_path):
    # Create a hash object using SHA-256
    sha256_hash = hashlib.sha256()

    # Open the file in binary mode
    with open(file_path, 'rb') as file:
        # Read the file in chunks of 4096 bytes
        for byte_block in iter(lambda: file.read(4096), b''):
            # Update the hash with the current chunk
            sha256_hash.update(byte_block)

    # Get the hexadecimal representation of the hash
    file_hash = sha256_hash.hexdigest()

    return file_hash

# Specify the path to the file
file_path = '/path/to/your/file.txt'

# Create a unique hash based on file name and size
unique_hash = generate_file_hash(file_path)

print(f'The unique hash for the file {file_path} is: {unique_hash}')