20 lines
510 B
Python
20 lines
510 B
Python
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) |