Files
nuriq_back/src/utils/func.py
윤영훈 ae2766cff5 [FEAT] (사용자 로직): 인증 서비스 로직 구현 중
v0.1.1 (2025-11-13)
- 사용자 관련 인증 서비스 로직 구현 중
2025-11-13 17:29:22 +09:00

30 lines
798 B
Python

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