import string
import secrets


def random_string(
    n: int = 8,
    *, _ALPHABET=''.join([string.ascii_lowercase, string.digits])
) -> str:
    """Generate a random string of lowercase ascii letters and digits.

    Parameters
    ----------
    n: int, optional
        The number of characters which the output string will have. Default=8
    """
    token = [secrets.choice(_ALPHABET) for i in range(n)]
    return ''.join(token)