cara membuat checksum ke file python

import hashlib

md5_hash = hashlib.md5()

a_file = open("test.txt", "rb")
content = a_file.read()
md5_hash.update(content)

digest = md5_hash.hexdigest()
print(digest)

'''
OUTPUT
4fcc82a88ee38e0aa16c17f512c685c9
'''
#Warning: Using a file that is too large may exceed system memory unless it broken into smaller chunks.
SharxNZ