Verify that Password Matches Argon2i Hash using Python

argon2-cffi library

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

ph = PasswordHasher()

password = 'Hello'
passwordHash = '$argon2i$v=19$m=65536,t=4,p=2$bXVoQnQzaG44SmNBdGozVg$EZnL39Yuww+IEs03LX1M48K9lz8XvXgD9uWsIbmh27E'
try:
    isValid = ph.verify(passwordHash, password)
except VerifyMismatchError:
    isValid = False

print(isValid)

Leave a Comment

Cancel reply

Your email address will not be published.