Add password hashing and verification functions using bcrypt

This commit is contained in:
Yoga Pangestu 2026-07-17 23:15:11 +07:00
parent ce71aa3ad8
commit 172f035d77

9
app/security.py Normal file
View File

@ -0,0 +1,9 @@
import bcrypt
def hash_password(password: str) -> str:
return bcrypt.hashpw(password.encode(), bcrypt.gensalt()).decode()
def verify_password(plain: str, hashed: str) -> bool:
return bcrypt.checkpw(plain.encode(), hashed.encode())