import random


def generate_token(length=64):
    """Generate a random token.

    Args:
        length (int): Number of characters in the token.

    Returns:
        Random character sequence.
    """
    _allowed = 'abcdefghijklmnoprstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-_$'
    token = ''.join(random.SystemRandom().choice(_allowed) for i in range(length))

    return token