>>> import hashlib
>>> hashlib.sha1(str.encode('testing 123')).hexdigest()
'b8dfb080bc33fb564249e34252bf143d88fc018f'
with a function:
>>> def check_hash(word):
... myhash = hashlib.sha1(str.encode(word)).hexdigest()
... if myhash == stored_hash:
... return 'hash exists'
... else:
... return 'hash does not exist'
store hash:
>>> hashlib.sha1(str.encode('testing 123')).hexdigest()
'b8dfb080bc33fb564249e34252bf143d88fc018f'
>>> stored_hash = 'b8dfb080bc33fb564249e34252bf143d88fc018f'
test function:
>>> print(check_hash('sweet'))
hash does not exist
>>> print(check_hash('testing 123'))
hash exists