[python]function That Compares Two Zip Files, One Located In Ftp Dir, The Other On My Local Machine
I have an issue creating function that compare two zip files(if they are the same, not only by name). Here is example of my code: def validate_zip_files(self): host = '192.168.
Solution 1:
Rather than comparing the files directly, I would go ahead and compare hashed values of the files. This eliminates the dependency of filecmp
, which might -as you said - not work with zipped files.
import hashlib
def compare_files(a,b):
fileA = hashlib.sha256(open(a, 'rb').read()).digest()
fileB = hashlib.sha256(open(b, 'rb').read()).digest()
if fileA == fileB:
return True
else:
return False
Post a Comment for "[python]function That Compares Two Zip Files, One Located In Ftp Dir, The Other On My Local Machine"