Coverage for app/ddd/infrastructure/auth/hash_password.py: 100%

1 statements  

« prev     ^ index     » next       coverage.py v7.6.10, created at 2025-01-15 01:44 +0000

1# passlibがメンテされていないので使わない 

2# https://github.com/pyca/bcrypt/issues/684 

3# https://fastapi.tiangolo.com/tutorial/security/oauth2-jwt/#install-passlib 

4import bcrypt 

5 

6 

7def verify_password(plain_password: str, hashed_password: str) -> bool: 

8 """hashed_passerdの確認.""" 

9 return bcrypt.checkpw(plain_password.encode(), hashed_password.encode()) 

10 

11def create_hashed_password(password: str) -> str: 

12 """hashed_passerdの作成.""" 

13 salt = bcrypt.gensalt(rounds=12, prefix=b"2a") 

14 return bcrypt.hashpw(password.encode(), salt).decode()