Skip to content

FEAT: Add Base91Converter (base91 binary-to-text encoding) - #4441

Open
Roman Lutz (romanlutz) wants to merge 1 commit into
microsoft:mainfrom
romanlutz:gap1-base91
Open

Roman Lutz (romanlutz) wants to merge 1 commit into
microsoft:mainfrom
romanlutz:gap1-base91

Conversation

@romanlutz

@romanlutz Roman Lutz (romanlutz) commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Adds a pure-Python Base91 binary-to-text converter (no third-party dependency) and registers it as an ALL-only technique in the garak Encoding scenario, with a unit test and a doc example.

Part of a series splitting the gap-1 converter set into reviewable per-converter / per-base PRs (template PR — opened as draft while the layout is confirmed).

🤖 Generated with Claude Code

gap-1 converter series — splitting the esoteric cipher / encoder set into reviewable PRs (open each independently; they touch the same four registration files, so later ones rebase as earlier ones merge):

Add a pure-Python Base91 converter (no third-party dependency) and register it as
an ALL-only technique in the garak Encoding scenario, with a unit test and a doc
example.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 19, 2026 23:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Expanding all prevents previously saved Encoding runs from resuming, and the Base91 encoder’s 14-bit branch lacks boundary and zero-value test coverage.

2 open issues
What changed in this PR

Adds dependency-free Base91 encoding to PyRIT’s converter library and makes it available in the garak Encoding scenario.

Changes:

  • Implements UTF-8 text-to-Base91 conversion and exposes it through lazy package exports.
  • Registers Base91 as an ALL-only encoding technique, leaving the default selection unchanged.
  • Adds converter unit tests and a Python-format documentation example.
File Description
tests/​unit/​scenario/​garak/​test_encoding.py Updates the technique count and ALL-only expectations.
tests/​unit/​converter/​test_base91_converter.py Tests known vectors, Unicode, empty input, and supported types.
pyrit/​scenario/​scenarios/​garak/​encoding.py Registers the Base91 technique and converter variant.
pyrit/​converter/​base91_converter.py Implements the pure-Python Base91 converter.
pyrit/​converter/​__init__.py Adds public lazy exports for Base91Converter.
doc/​code/​converters/​1_text_to_text_converters.py Adds a Base91 conversion example.

Review effort: Balanced

LeetSpeak = ("leet_speak", {"default"})
AsciiSmuggler = ("ascii_smuggler", set[str]())
Bifid = ("bifid", set[str]())
Base91 = ("base91", set[str]())
# Reference basE91 vector: "Hello World!" -> ">OwJh>Io0Tv!8PE".
converter = Base91Converter()
result = await converter.convert_async(prompt="Hello World!", input_type="text")
assert result.output_text == ">OwJh>Io0Tv!8PE"

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants