Rescue Paperjet v1 implementation
This commit is contained in:
parent
7ff5c8130d
commit
db9e2ca51b
83 changed files with 6186 additions and 3894 deletions
|
|
@ -1,20 +1,22 @@
|
|||
"""Argon2id password hashing and verification."""
|
||||
|
||||
from argon2 import PasswordHasher
|
||||
from argon2.exceptions import VerifyMismatchError
|
||||
from argon2.exceptions import InvalidHashError, VerifyMismatchError
|
||||
|
||||
# Argon2id is the default for PasswordHasher
|
||||
ph = PasswordHasher()
|
||||
|
||||
|
||||
def hash_password(password: str) -> str:
|
||||
"""Hash a plaintext password."""
|
||||
return ph.hash(password)
|
||||
|
||||
|
||||
def verify_password(hashed: str, password: str) -> bool:
|
||||
"""Verify a password against a hash. Returns True if matched."""
|
||||
try:
|
||||
ph.verify(hashed, password)
|
||||
# Note: We skip check_needs_rehash() for simplicity in this single-user app.
|
||||
return True
|
||||
except VerifyMismatchError:
|
||||
except (InvalidHashError, VerifyMismatchError):
|
||||
return False
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue