BoxTitoli_Mysql/random_id/utils.py

12 lines
383 B
Python
Executable File

import random
import string
ALPHANUMERIC_CHARS = string.ascii_lowercase + string.ascii_uppercase + string.digits
MIN_STRING_LENGTH = 11
MAX_STRING_LENGTH = 27
random_string_length = random.randint(MIN_STRING_LENGTH,MAX_STRING_LENGTH)
def generate_random_string(chars=ALPHANUMERIC_CHARS,length=random_string_length):
return "".join(random.choice(chars) for _ in range(length))