import secrets


def random_file_name(filename: str) -> str:
    """
    Replace file name with a random string and preserving its extension.
    Result would look like <random_string>.<extension>

    :param filename: str
    :return: str
    """
    return f'{secrets.token_urlsafe(16)}.{filename.split(".")[-1]}'