def _get_masked_string(text, mask_value, index):
    """Return masked string.

    :Note: If the mask length will cause the final string to be longer
        than the original string, then the mask will be cut down to
        size.
    """
    end_index = index + len(mask_value)
    text_length = len(text)
    if text_length - 1 < end_index:
        temp_string = f'{text[:index]}{mask_value}'
        return temp_string[:text_length]
    return f'{text[:index]}{mask_value}{text[end_index:]}'
