pyrit.prompt_converter.AsciiSmugglerConverter#
- class AsciiSmugglerConverter(action: Literal['encode', 'decode'] = 'encode', unicode_tags: bool = False)[source]#
Bases:
SmugglerConverter
Implements encoding and decoding using Unicode Tags.
- If ‘control’ is True, the encoded output is wrapped with:
U+E0001 (start control tag)
U+E007F (end control tag)
Replicates the functionality detailed in the following blog post: https://embracethered.com/blog/posts/2024/hiding-and-finding-text-with-unicode-tags/
- __init__(action: Literal['encode', 'decode'] = 'encode', unicode_tags: bool = False)[source]#
Initializes the converter with options for encoding/decoding.
- Parameters:
action (Literal["encode", "decode"]) – The action to perform.
unicode_tags (bool) – Whether to add Unicode tags during encoding.
Methods
__init__
([action, unicode_tags])Initializes the converter with options for encoding/decoding.
convert_async
(*, prompt[, input_type])Converts the given prompt by either encoding or decoding it based on the specified action.
convert_tokens_async
(*, prompt[, ...])Converts substrings within a prompt that are enclosed by specified start and end tokens.
decode_message
(*, message)Decodes a message encoded with Unicode Tags.
encode_message
(*, message)Encodes the message using Unicode Tags.
get_identifier
()Returns an identifier dictionary for the converter.
input_supported
(input_type)Checks if the input type is supported by the converter.
output_supported
(output_type)Checks if the output type is supported by the converter.
Attributes
supported_input_types
Returns a list of supported input types for the converter.
supported_output_types
Returns a list of supported output types for the converter.
- decode_message(*, message: str)[source]#
Decodes a message encoded with Unicode Tags.
For each character in the Unicode Tags range, subtracts 0xE0000. Skips control tags if present.