Spaces:
Runtime error
Runtime error
Download auth/passwords.py from MaheenGhouri/fullstack_todo_app: direct link, hf CLI and curl.
- Browser
- Download file 511 Bytes
-
https://huggingface.co/spaces/MaheenGhouri/fullstack_todo_app/resolve/main/auth/passwords.py
- Command line
-
hf download hf://spaces/MaheenGhouri/fullstack_todo_app/auth/passwords.py
-
curl -L -o passwords.py https://huggingface.co/spaces/MaheenGhouri/fullstack_todo_app/resolve/main/auth/passwords.py
511 Bytes
| import bcrypt | |
| def hash_password(password: str): | |
| """Hash a password using bcrypt""" | |
| password_bytes = password.encode('utf-8') | |
| salt = bcrypt.gensalt() | |
| return bcrypt.hashpw(password_bytes, salt).decode('utf-8') | |
| def verify_password(plain_password: str, hashed_password: str): | |
| """Verify a plain password against the hashed password""" | |
| password_bytes = plain_password.encode('utf-8') | |
| hashed_bytes = hashed_password.encode('utf-8') | |
| return bcrypt.checkpw(password_bytes, hashed_bytes) |