cyberchef/src/core/operations/ToBase91.mjs
Izai Alejandro Zalles Merino aa4bb2b415 Add Base91 encoding/decoding operations
- 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 <zallesrene@gmail.com>
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
2025-10-01 12:30:40 -04:00

40 lines
1.2 KiB
JavaScript

/**
* @author Izai Alejandro Zalles Merino <zallesrene@gmail.com> (ialejandrozalles)
* @copyright © 2025 Izai Alejandro Zalles Merino
* @license Apache-2.0
*/
import { encodeBase91 } from "../lib/Base91.mjs";
import Operation from "../Operation.mjs";
/**
* To Base91 operation
*/
class ToBase91 extends Operation {
/**
* ToBase91 constructor
*/
constructor() {
super();
this.name = "To Base91";
this.module = "Default";
this.description = "Base91 is a binary-to-text encoding scheme that uses 91 printable ASCII characters. It provides better space efficiency than Base64 while maintaining readability. Base91 encodes arbitrary binary data using characters A-Z, a-z, 0-9, and various symbols (excluding hyphen, backslash, and single quote).";
this.infoURL = "https://en.wikipedia.org/wiki/Binary-to-text_encoding#Encoding_standards";
this.inputType = "ArrayBuffer";
this.outputType = "string";
}
/**
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
const data = new Uint8Array(input);
return encodeBase91(data);
}
}
export default ToBase91;