newbie playing around with hashes here and not getting the result I am looking for. Trying to get a hash from a txt file from the web, then comparing that hash to a local hash.
For testing purposes I'm using SHA256.new(“10”).hexdigest() which is: 4a44dc15364204a80fe80e9039455cc1608281820fe2b24f1e5233ade6af1dd5
CODE:
import urllib2
from Crypto.Hash import SHA256
source = urllib2.urlopen("<xxURLxx>")
line1 = source.readline() # get first line of the txt file in source which is the hash
localHash = SHA256.new("10").hexdigest()
if localHash == line1: # I know, shouldnt use == to compare hashes but it is my first try.
print("it works!")
else:
print("it does not work...")
Printing the hashes I get from the web file and the local hash they return the same characters. But if I hash each hash one more time I get different results.
Any ideas?
Had a look around S.O. and found: Compare result from hexdigest() to a string but the issue there was the lack of .digest() which I have.
Thank you in advance for any help.