Verify that Password Matches Argon2id Hash using Python

argon2-cffi library

  1. Install argon2-cffi library from the command line:
pip install argon2-cffi
  1. Verify that password matches Argon2id hash:
from argon2 import PasswordHasher
from argon2.exceptions import VerifyMismatchError

ph = PasswordHasher()

password = 'Hello'
passwordHash = '$argon2id$v=19$m=65536,t=4,p=2$Sk05cXZxbUhJQ1E5em02dQ$K8U9+ltV14jERcG5v8fMpcRFg75dz49AipKwEQseuoc'
try:
    isValid = ph.verify(passwordHash, password)
except VerifyMismatchError:
    isValid = False

print(isValid)

Leave a Comment

Cancel reply

Your email address will not be published.