Feat: [#10] 코드생성 및 유효기간 설정 로직 구현

This commit is contained in:
sm4640
2025-03-27 16:53:28 +09:00
parent ed207f62dc
commit b8a8ff177b

View File

@@ -0,0 +1,20 @@
from random import randint, choices
from django.utils.timezone import now
from datetime import timedelta
import ulid, uuid
def generate_ulid():
return str(ulid.ULID())
def generate_uuid():
return str(uuid.uuid4())
allowed_char = ''.join(chr(i) for i in range(33, 127) if chr(i).isalnum())
def generate_code(code_len): # 코드 생성
code = ''.join(choices(allowed_char, k=code_len))
return code
def set_expire(minutes): # 유효기간 설정
return now() + timedelta(minutes=minutes)