BoxTitoli_Mysql/random_id/utils.py

12 lines
383 B
Python
Raw Permalink Normal View History

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