[FEAT] (사용자 로직): 인증 서비스 로직 구현 중
v0.1.1 (2025-11-13) - 사용자 관련 인증 서비스 로직 구현 중
This commit is contained in:
30
src/utils/func.py
Normal file
30
src/utils/func.py
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
def get_timestamp_ms():
|
||||
"""타임스탬프 생성"""
|
||||
import time
|
||||
return round(time.time() * 1000)
|
||||
|
||||
def hash_password(password: str) -> str:
|
||||
"""비밀번호 암호화"""
|
||||
import bcrypt
|
||||
|
||||
if not password:
|
||||
raise ValueError("비밀번호는 비어있을 수 없습니다.")
|
||||
|
||||
hashed = bcrypt.hashpw(password.encode("utf-8"), bcrypt.gensalt())
|
||||
return hashed.decode("utf-8")
|
||||
|
||||
def verify_password(password: str, hashed_password: str) -> bool:
|
||||
import bcrypt
|
||||
|
||||
"""비밀번호 검증"""
|
||||
if not password or not hashed_password:
|
||||
return False
|
||||
|
||||
try:
|
||||
return bcrypt.checkpw(
|
||||
password.encode("utf-8"),
|
||||
hashed_password.encode("utf-8")
|
||||
)
|
||||
except (ValueError, AttributeError):
|
||||
return False
|
||||
Reference in New Issue
Block a user