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]#
Initialize the converter with options for encoding/decoding.
- Parameters:
unicode_tags (bool) – Whether to add Unicode tags during encoding.
Methods
__init__
([action, unicode_tags])Initialize the converter with options for encoding/decoding.
convert_async
(*, prompt[, input_type])Convert the 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
()input_supported
(input_type)Return True if the input type is 'text'.
output_supported
(output_type)Return True if the output type is 'text'.
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.