import string
import secrets


def random_password(length=24, punctuation=False):
    """
    Generate a random password.

    Args:
        length (int): The password length (default 24).
        punctuation (bool): Whether punctuation is used (default False).

    Returns:
        password (str): The generated password.
    """
    source = string.ascii_letters+string.digits
    if punctuation:
        source += '!@#$%^&*()<>[]{}-+=/'
    r = secrets.SystemRandom()
    return ''.join(r.choice(source) for _ in range(length))