import string
import secrets


def random_string(length:int = 1024, ascii:bool = True, digits:bool = True) -> str:
    """Generate a random alphanumeric string of size `length`
    
    Keyword arguments:
    Argument: length:int (defaults to 128), 
    Return: string
    """
    alphabet = []
    if ascii: alphabet += string.ascii_letters
    elif digits: alphabet += string.digits
    else: raise SyntaxError("bool or digits should either be True")
    return ''.join(secrets.choice(alphabet) for i in range(length))