Skip to content

Generators

generate_random_id

def generate_random_id(chars=7): ...

Generates a random alphanumeric string (ASCII letters and digits) of the given length. Defaults to 7 characters.

Parameter Type Default Description
chars int 7 Length of the generated id
generate_random_id()        # e.g. "aZ3kLo9"
generate_random_id(chars=12)

Note

This is not cryptographically secure — it uses random.choices, not secrets. Don't use it for tokens, passwords, or anything security-sensitive.