I have two files a.txt and b.txt, So i am trying to compare using hash like below.
#getting hash of files and comparing
file1 = hashlib.md5(open('a.txt', 'rb').read()).hexdigest()
file2 = hashlib.md5(open('b.txt', 'rb').read()).hexdigest()
file1==file2--> returns True or False
this is one way and also we can do using filecmp as below
filecmp.cmp('a.txt','b.txt')--> returns True or False
In both of these ways which is better and why?