I am calling bcrypt.checkpw
to check unencrypted password matches with hashed password stored in the credential database, but receive
TypeEr
Using that like e.g. and see the comments below the code:
import bcrypt
def comparacaoSenha(passw, hash):
if bcrypt.checkpw(passw, hash):
print("It Matches!")
else:
print("It Does not Match")
password = "super secret password".encode('utf-8')
password2 = "another password".encode('utf-8')
hashed = bcrypt.hashpw(password, bcrypt.gensalt())
heashed2 = bcrypt.hashpw(password2, bcrypt.gensalt())
print("Teste 1: ")
print("-----------------------------")
print("PASSWORD: ", password)
print("HASHED PW: ", hashed)
comparacaoSenha(password, hashed)
print("-----------------------------")
print("Teste 2: ")
print("-----------------------------")
print("PASSWORD: ", password2)
print("HASHED PW: ", heashed2)
comparacaoSenha(password2, heashed2)
print("-----------------------------")
# Things to remember:
# always use the encode('utf-8') or put a prefix 'b'' just before the strings
# EX: newPass = b"OTHER PASSWORD" // or newPass="OTHER PASSWORD".encode('utf-8')
#