Skip to content

Instantly share code, notes, and snippets.

@widhisec
Last active December 5, 2023 16:12
Show Gist options
  • Save widhisec/f7345adbe7558707653ca2de385ec81c to your computer and use it in GitHub Desktop.
Save widhisec/f7345adbe7558707653ca2de385ec81c to your computer and use it in GitHub Desktop.
generator
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