I have a list of filenames and I wish to find the checksum of the each file and store in a list displaying [filename,checksum].
New to programming so I tried creating a for loop taking the files from directory. I then used hashlib.md5 to open file with its path and print the filename alongside the checksum.
directory = os.listdir(path)
def file_as_bytes(file):
with file:
return file.read()
for fx in directory:
pass
print[(fx, hashlib.md5(file_as_bytes(open(fx, 'rb'))).digest())]
This is the error I obtain:
IOError: [Errno 2] No such file or directory: 'c.txt'
Which I never created in my client. I only wish to display the checksum of each file that I have in my client (that already exist)