pyrit.prompt_converter.BinAsciiConverter#
- class BinAsciiConverter(*, encoding_func: Literal['hex', 'quoted-printable', 'UUencode'] = 'hex', indices: List[int] | None = None, keywords: List[str] | None = None, proportion: float | None = None, regex: str | Pattern | None = None, word_split_separator: str | None = ' ')[source]#
Bases:
WordLevelConverter
Converts text to various binary-to-ASCII encodings.
Supports hex, quoted-printable, and UUencode formats.
- __init__(*, encoding_func: Literal['hex', 'quoted-printable', 'UUencode'] = 'hex', indices: List[int] | None = None, keywords: List[str] | None = None, proportion: float | None = None, regex: str | Pattern | None = None, word_split_separator: str | None = ' ') None [source]#
Initialize the BinAsciiConverter.
- Parameters:
encoding_func (str) – The encoding function to use. Options: “hex”, “quoted-printable”, “UUencode”. Defaults to “hex”.
indices (Optional[List[int]]) – Specific indices of words to convert.
keywords (Optional[List[str]]) – Keywords to select words for conversion.
proportion (Optional[float]) – Proportion of randomly selected words to convert [0.0-1.0].
regex (Optional[Union[str, re.Pattern]]) – Regex pattern to match words for conversion.
word_split_separator (Optional[str]) – Separator used to split words in the input text. Defaults to “ “.
Methods
__init__
(*[, encoding_func, indices, ...])Initialize the BinAsciiConverter.
convert_async
(*, prompt[, input_type])Converts the given prompt into the target format supported by the converter.
convert_tokens_async
(*, prompt[, ...])Converts substrings within a prompt that are enclosed by specified start and end tokens.
convert_word_async
(word)Convert a word using the specified encoding function.
get_identifier
()Returns an identifier dictionary for the converter.
input_supported
(input_type)Checks if the input type is supported by the converter.
join_words
(words)Join words appropriately based on the encoding type and mode.
output_supported
(output_type)Checks if the output type is supported by the converter.
validate_input
(prompt)Validates the input before processing (can be overridden by subclasses).
Attributes
alias of
Literal
['hex', 'quoted-printable', 'UUencode']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.