pyrit.prompt_converter.SneakyBitsSmugglerConverter#
- class SneakyBitsSmugglerConverter(action: Literal['encode', 'decode'] = 'encode', zero_char: str | None = None, one_char: str | None = None)[source]#
Bases:
SmugglerConverterEncodes and decodes text using a bit-level approach.
- Uses two invisible Unicode characters:
zero_char(default: U+2062) to represent binary 0.one_char(default: U+2064) to represent binary 1.
- Replicates functionality detailed in:
- __init__(action: Literal['encode', 'decode'] = 'encode', zero_char: str | None = None, one_char: str | None = None)[source]#
Initialize the converter with options for encoding/decoding in Sneaky Bits mode.
- Parameters:
- Raises:
ValueError – If an unsupported action or
encoding_modeis provided.
Methods
__init__([action, zero_char, one_char])Initialize the converter with options for encoding/decoding in Sneaky Bits mode.
convert_async(*, prompt[, input_type])Convert the given prompt by either encoding or decoding it based on the specified action.
convert_tokens_async(*, prompt[, ...])Convert substrings within a prompt that are enclosed by specified start and end tokens.
decode_message(message)Decode the message encoded using Sneaky Bits mode.
encode_message(message)Encode the message using Sneaky Bits mode.
get_identifier()Get the typed identifier for this object.
input_supported(input_type)Check if the input type is supported by the converter.
output_supported(output_type)Check if the output type is supported.
Attributes
SUPPORTED_INPUT_TYPESTuple of input modalities supported by this converter.
SUPPORTED_OUTPUT_TYPESTuple of output modalities supported by this converter.
supported_input_typesReturns a list of supported input types for the converter.
supported_output_typesReturns a list of supported output types for the converter.
- decode_message(message: str) str[source]#
Decode the message encoded using Sneaky Bits mode.
The method filters out only the valid invisible characters (
self.zero_charandself.one_char), groups them into 8-bit chunks, reconstructs each byte, and finally decodes the byte sequence using UTF-8.