File tree Expand file tree Collapse file tree 2 files changed +12
-9
lines changed
Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,6 @@ dependencies = [
6060 " Flask>=3.1.1" ,
6161 " Flask-Login>=0.6.3" ,
6262 " cryptography>=45.0.5" ,
63- " passlib>=1.7.4" ,
6463 " bcrypt>=4.0.0" ,
6564 " flask-wtf>=1.2.1" ,
6665 " flask-limiter>=3.8.0" ,
Original file line number Diff line number Diff line change 22from base64 import b64decode , b64encode
33from typing import cast
44
5+ import bcrypt
56from cryptography .fernet import Fernet
67from dotenv import load_dotenv
7- from passlib .context import CryptContext
88
99from logging_config import get_logger
1010
1111load_dotenv ()
1212
1313logger = get_logger (__name__ )
1414
15- # --- Password Hashing ---
16- pwd_context = CryptContext (schemes = ["bcrypt" ], deprecated = "auto" )
17-
1815
1916def verify_password (plain_password : str , hashed_password : str ) -> bool :
20- """Verify a plain password against its hash."""
2117 try :
22- return bool (pwd_context .verify (plain_password , hashed_password ))
18+ return bool (
19+ bcrypt .checkpw (
20+ plain_password .encode ("utf-8" )[:72 ],
21+ hashed_password .encode ("utf-8" ),
22+ )
23+ )
2324 except Exception as e :
2425 logger .error ("password_verification_error" , error = str (e ))
2526 return False
2627
2728
2829def get_password_hash (password : str ) -> str :
29- """Generate password hash."""
30- return str (pwd_context .hash (password ))
30+ hashed : bytes = bcrypt .hashpw (
31+ password .encode ("utf-8" )[:72 ],
32+ bcrypt .gensalt (),
33+ )
34+ return hashed .decode ("utf-8" )
3135
3236
3337# --- Per-User Credential Encryption ---
You can’t perform that action at this time.
0 commit comments