from __future__ import annotations from secrets import choice, token_hex from uuid import uuid4 REFERRAL_ALPHABET = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789" def new_object_id() -> str: return uuid4().hex def new_public_token(length: int = 20) -> str: return token_hex(length // 2 + 1)[:length] def new_referral_code(length: int = 8) -> str: return "".join(choice(REFERRAL_ALPHABET) for _ in range(length))