Last active
December 5, 2023 16:12
-
-
Save widhisec/f7345adbe7558707653ca2de385ec81c to your computer and use it in GitHub Desktop.
generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import string | |
import random | |
class UIDGenerator: | |
def __init__(self, uid_length=7, token_length=6): | |
self.uid_length = uid_length | |
self.token_length = token_length | |
def generate_uid(self): | |
characters = string.ascii_lowercase + string.digits | |
uid = ''.join(random.choice(characters) for _ in range(self.uid_length)) | |
return uid | |
def generate_token(self): | |
characters = string.ascii_lowercase + string.digits | |
token = ''.join(random.choice(characters) for _ in range(self.token_length)) | |
return token | |
uid_generator = UIDGenerator() | |
uid = uid_generator.generate_uid() | |
token = uid_generator.generate_token() | |
print("UID:", uid) | |
print("Token:", token) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment