def id_generator(size=15, chars=string.ascii_uppercase + string.digits): """ Generates a random identifier for the given size and using the specified characters. If no size is specified, it uses 15 as default. If no characters are specified, it uses ascii char upper case and digits. :arg size: the size of the identifier to return. :arg chars: the list of characters that can be used in the idenfitier. """ return "".join(random_choice(chars) for x in range(size))
def _api_token_generator(charset=string.ascii_letters + string.digits, length=40): """ Generate an API token of a given length using the provided character set. Args: charset (str): A string of characters to choose from in the token. length (int): The number of characters to use in the token. Returns: str: The API token as a unicode string. """ return u''.join(random_choice(charset) for __ in range(length))
def _api_token_generator(charset=string.ascii_letters + string.digits, length=40): """ Generate an API token of a given length using the provided character set. Args: charset (str): A string of characters to choose from in the token. length (int): The number of characters to use in the token. Returns: str: The API token as a unicode string. """ return u"".join(random_choice(charset) for __ in range(length))
def create_nonce_str(): return ''.join( random_choice(string.ascii_letters + string.digits) for _ in range(15))