Skip to content

Conversation

ialejandrozalles
Copy link

Overview

This PR adds complete Base91 encoding/decoding operations to CyberChef, providing users with an additional binary-to-text encoding option that offers better space efficiency than Base64.

What is Base91?

Base91 is a binary-to-text encoding scheme that uses 91 printable ASCII characters, developed by Joachim Henke. It provides approximately 2.5% better space efficiency compared to Base64 while maintaining human readability and compatibility with text-based protocols.

Changes Made

New Files Added:

  • src/core/lib/Base91.mjs - Core Base91 implementation library with encoding/decoding functions
  • src/core/operations/ToBase91.mjs - Base91 encoding operation for CyberChef interface
  • src/core/operations/FromBase91.mjs - Base91 decoding operation for CyberChef interface
  • Updated src/core/config/Categories.json - Added Base91 operations to the 'Data format' category

Features

  • Complete Implementation: Full Base91 encoder and decoder based on the original basE91 algorithm
  • Space Efficient: ~2.5% better space efficiency compared to Base64
  • 91 Character Alphabet: Uses printable ASCII characters excluding hyphen, backslash, and single quote
  • Error Handling: Proper validation and error reporting for invalid Base91 input
  • Documentation: Complete JSDoc documentation for all functions
  • Type Safety: Proper input/output type definitions (ArrayBuffer ↔ string)

Technical Details

  • Algorithm: Based on basE91 by Joachim Henke (http://base91.sourceforge.net/)
  • Character Set: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%&()*+,./:;<=>?@[]^_`{|}~"`
  • Input Types: ArrayBuffer for encoding, string for decoding
  • Output Types: String for encoding, ArrayBuffer for decoding
  • No Padding: Unlike Base64, Base91 doesn't use padding characters

Use Cases

Base91 is particularly useful for:

  • Data transmission over text-based protocols where space efficiency matters
  • Encoding binary data for embedding in text files or JSON
  • Scenarios requiring better space utilization than Base64
  • Applications where the slightly larger character set is acceptable

Testing

The implementation has been tested with:

  • Various binary data types and sizes
  • Edge cases (empty input, single bytes, large data)
  • Invalid input validation
  • Round-trip encoding/decoding verification

Compatibility

  • No breaking changes to existing CyberChef functionality
  • Follows existing CyberChef coding patterns and standards
  • Compatible with all CyberChef supported environments (web, Node.js)

Author

Izai Alejandro Zalles Merino
Email: [email protected]
GitHub: @ialejandrozalles

References


This addition enhances CyberChef's binary-to-text encoding capabilities and provides users with more efficient options for data encoding scenarios.

- Add complete Base91 implementation based on Joachim Henke's basE91 algorithm
- Includes both encoding (ToBase91) and decoding (FromBase91) operations
- Uses 91 printable ASCII characters for optimal space efficiency
- Better space efficiency than Base64 while maintaining readability
- Proper error handling for invalid characters during decoding
- Full JSDoc documentation

Files added:
- src/core/lib/Base91.mjs - Core Base91 implementation library
- src/core/operations/ToBase91.mjs - Base91 encoding operation
- src/core/operations/FromBase91.mjs - Base91 decoding operation
- Updated Categories.json to include Base91 operations

Author: Izai Alejandro Zalles Merino <[email protected]>
Technical details:
- Algorithm: Based on basE91 by Joachim Henke (http://base91.sourceforge.net/)
- Alphabet: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%&()*+,./:;<=>?@[]^_`{|}~"
- Input types: ArrayBuffer for encoding, string for decoding
- Output types: string for encoding, ArrayBuffer for decoding
Update chef.help() test to expect 15 results instead of 13
due to the addition of Base91 operations (ToBase91 and FromBase91)
which are now included when searching for 'base 64'.
@ialejandrozalles ialejandrozalles force-pushed the feature/add-base91-official branch from 33c9fbf to d6ec763 Compare October 1, 2025 16:54
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.

1 participant