NOVA-Openclaw 3b3eb2f78e Add To Base26 and From Base26 operations
Implements Base26 encoding/decoding using uppercase A-Z as digits
(A=0, B=1, ..., Z=25). Input bytes are interpreted as a big-endian
unsigned integer and converted to/from radix 26.

Includes tests for the reference vector (EAT -> JYGBS), round-trips,
empty input, zero bytes, and binary data.

Closes gchq/CyberChef#1511
2026-07-26 22:33:34 +00:00

150 lines
3.2 KiB
JavaScript

/**
* Base26 tests.
*
* @author NOVA-Openclaw
*
* @copyright Crown Copyright 2026
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "To Base26: nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "To Base26",
args: [],
},
],
},
{
name: "To Base26: EAT -> JYGBS",
input: "EAT",
expectedOutput: "JYGBS",
recipeConfig: [
{
op: "To Base26",
args: [],
},
],
},
{
name: "To Base26: Hello, World!",
input: "Hello, World!",
expectedOutput: "LBVLPVLUNRXHXRHSZIHQLL",
recipeConfig: [
{
op: "To Base26",
args: [],
},
],
},
{
name: "To Base26: UTF-8",
input: "ნუ პანიკას",
expectedOutput: "HLPHPKXWXPTREJHEBQENHKRQAKLFKOWIWEXTDNAOPRQFRQLL",
recipeConfig: [
{
op: "To Base26",
args: [],
},
],
},
{
name: "To Base26: zero byte",
input: "\x00",
expectedOutput: "A",
recipeConfig: [
{
op: "To Base26",
args: [],
},
],
},
{
name: "To Base26: binary",
input: "\x01\x02\x03",
expectedOutput: "DTSL",
recipeConfig: [
{
op: "To Base26",
args: [],
},
],
},
{
name: "From Base26: nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "From Base26",
args: [],
},
],
},
{
name: "From Base26: JYGBS -> EAT",
input: "JYGBS",
expectedOutput: "EAT",
recipeConfig: [
{
op: "From Base26",
args: [],
},
],
},
{
name: "From Base26: lowercase and ignored characters",
input: "j y-g!b@s",
expectedOutput: "EAT",
recipeConfig: [
{
op: "From Base26",
args: [],
},
],
},
{
name: "From Base26: A -> zero byte",
input: "A",
expectedOutput: "\x00",
recipeConfig: [
{
op: "From Base26",
args: [],
},
],
},
{
name: "From Base26: DTSL -> binary",
input: "DTSL",
expectedOutput: "\x01\x02\x03",
recipeConfig: [
{
op: "From Base26",
args: [],
},
],
},
{
name: "To Base26 round-trip",
input: "The quick brown fox jumps over the lazy dog.",
expectedOutput: "The quick brown fox jumps over the lazy dog.",
recipeConfig: [
{
op: "To Base26",
args: [],
},
{
op: "From Base26",
args: [],
},
],
}
]);