pyrit.prompt_converter.SneakyBitsSmugglerConverter#

class SneakyBitsSmugglerConverter(action: Literal['encode', 'decode'] = 'encode', zero_char: str | None = None, one_char: str | None = None)[source]#

Bases: SmugglerConverter

Encodes 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]#

Initializes the converter with options for encoding/decoding in Sneaky Bits mode.

Parameters:
  • action (Literal["encode", "decode"]) – The action to perform.

  • zero_char (Optional[str]) – Character to represent binary 0 in sneaky_bits mode (default: U+2062).

  • one_char (Optional[str]) – Character to represent binary 1 in sneaky_bits mode (default: U+2064).

Raises:

ValueError – If an unsupported action or encoding_mode is provided.

Methods

__init__([action, zero_char, one_char])

Initializes the converter with options for encoding/decoding in Sneaky Bits mode.

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 the message encoded using Sneaky Bits mode.

encode_message(message)

Encodes the message using Sneaky Bits mode.

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) str[source]#

Decodes the message encoded using Sneaky Bits mode.

The method filters out only the valid invisible characters (self.zero_char and self.one_char), groups them into 8-bit chunks, reconstructs each byte, and finally decodes the byte sequence using UTF-8.

Parameters:

message (str) – The message encoded with Sneaky Bits.

Returns:

The decoded original message.

Return type:

str

encode_message(message: str) Tuple[str, str][source]#

Encodes the message using Sneaky Bits mode.

The message is first converted to its UTF-8 byte sequence. Then each byte is represented as 8 bits, with each bit replaced by an invisible character (self.zero_char for 0 and self.one_char for 1).

Parameters:

message (str) – The message to encode.

Returns:

A tuple where the first element is a bit summary (empty in this implementation) and the second element is the encoded message containing the invisible bits.

Return type:

Tuple[str, str]