I have looked through several topics about calculating checksums of files in Python but none of them answered the question about one sum from multiple files. I have several files in sub directories and would like to determine if there was any change in one or more of them. Is there a way to generate one sum from multiple files?
EDIT: This is the way I do it to get a list of sums:
checksums = [(fname, hashlib.md5(open(fname, 'rb').read()).digest()) for fname in flist]
Slightly cleaner than Artur's answer. There's no need to treat the first element specially.
(You can remove the
os.path.isfile()
if you like.)So I made it :) This way one hash sum is generated for a file list.
Thank you PM 2Ring for your input!
Note that md5 has been cracked so use it only for non security critical purposes.