I'm trying to create a simple software that includes the user having a password. I thought that instead of saving the password in the code as text, maybe try to learn a bit about how hashing works. I then tried to use the hashlib library for python. To me this code should be able to see that the passwords x and y match and therefore continue the hypothetical "login", but for some reason it doesn't do what I want it to do. Is there a syntax error? does password matching work in a different way? I need help to make the software compare 2 hashes and therefore login.
import hashlib
pw1=hashlib.md5(input("please enter your password").encode('utf-8'))
pw2=hashlib.md5(input("please re-enter your password").encode('utf-8'))
if pw1.hexdigest == pw2.hexdigest:
print("Success. Passwords match")
if pw1.hexdigest != pw2.hexdigest:
print("Failure. Passwords do not match")