Files
pay-service/src/infrastructure/security/hash.py

15 lines
483 B
Python

import bcrypt
from src.application.contracts import IHashService, ILogger
class HashService(IHashService):
def __init__(self, logger: ILogger):
self._logger = logger
async def hash(self, value: str) -> str:
hashed_value = bcrypt.hashpw(value.encode(), bcrypt.gensalt())
return hashed_value.decode()
async def verify(self, hashed_value: str, plain_value: str) -> bool:
return bcrypt.checkpw(plain_value.encode(), hashed_value.encode())