Source code for pyrit.prompt_converter.rot13_converter
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import codecs
from pyrit.models import PromptDataType
from pyrit.prompt_converter import PromptConverter, ConverterResult
[docs]
class ROT13Converter(PromptConverter):
[docs]
async def convert_async(self, *, prompt: str, input_type: PromptDataType = "text") -> ConverterResult:
"""
Simple converter that just ROT13 encodes the prompts
"""
if not self.input_supported(input_type):
raise ValueError("Input type not supported")
result = ConverterResult(output_text=codecs.encode(prompt, "rot13"), output_type="text")
return result