Verify that Password Matches bcrypt Hash using Python

bcrypt library

  1. Install bcrypt library from the command line:
pip install bcrypt
  1. Verify that password matches bcrypt hash:
import bcrypt

cost = 14

password = 'Hello'
passwordHash = '$2b$14$4Xq60qoHFfSNmcio3N2DzOOuqO0etK7t3qXyKvbPG.4xh24Zlh6Hq'
isValid = bcrypt.checkpw(password.encode('utf-8'), passwordHash.encode('utf-8'))

print(isValid)

Leave a Comment

Cancel reply

Your email address will not be published.