gchq/CyberChef · error · OperationError
Alphabet must be of length 85
Error message
Alphabet must be of length 85
What it means
Thrown by From Base85 when the supplied alphabet, after expandAlphRange expansion, does not have exactly 85 unique characters. Ascii85/Base85 requires an 85-symbol alphabet; both length and uniqueness are verified. This is a configuration error on the Alphabet argument.
Source
Thrown at src/core/operations/FromBase85.mjs:91
args: ["0-9A-Za-z!#$%&()*+\\-;<=>?@^_`{|}~"],
},
];
}
/**
* @param {string} input
* @param {Object[]} args
* @returns {byteArray}
*/
run(input, args) {
const alphabet = Utils.expandAlphRange(args[0]).join(""),
removeNonAlphChars = args[1],
allZeroGroupChar = typeof args[2] === "string" ? args[2].slice(0, 1) : "",
result = [];
if (alphabet.length !== 85 ||
[].unique.call(alphabet).length !== 85) {
throw new OperationError("Alphabet must be of length 85");
}
if (allZeroGroupChar && alphabet.includes(allZeroGroupChar)) {
throw new OperationError("The all-zero group char cannot appear in the alphabet");
}
// Remove delimiters if present
const matches = input.match(/^<~(.+?)~>$/);
if (matches !== null) input = matches[1];
// Remove non-alphabet characters
if (removeNonAlphChars) {
const re = new RegExp("[^~" + allZeroGroupChar +alphabet.replace(/[[\]\\\-^$]/g, "\\$&") + "]", "g");
input = input.replace(re, "");
// Remove delimiters again if present (incase of non-alphabet characters in front/behind delimiters)
const matches = input.match(/^<~(.+?)~>$/);
if (matches !== null) input = matches[1];
}View on GitHub (pinned to 4290ea7539)
Solutions
- Use a built-in preset (!-u, the IPv6 variant, z85) rather than a hand-typed alphabet.
- If custom, verify exactly 85 unique characters.
- Check expandAlphRange output if using A-Z style ranges.
Example fix
// before: 84-char alphabet fromBase85.run(input, ['!-t']) // expands to 84 // after: standard Ascii85 range (85) fromBase85.run(input, ['!-u'])
Defensive patterns
Strategy: validation
Validate before calling
const alphabet = Utils.expandAlphRange(args[0]).join('');
const unique = new Set(alphabet.split(''));
if (alphabet.length !== 85 || unique.size !== 85) {
// use a built-in preset (!-u, z85, IPv6); do not call fromBase85.run()
} Type guard
function isValidBase85Alphabet(a) {
return a.length === 85 && new Set(a).size === 85;
} Try / catch
try {
fromBase85.run(input, args);
} catch (e) {
if (e.type === 'OperationError' && /Alphabet must be of length 85/.test(e.message)) {
// reset alphabet to a built-in preset
} else throw e;
} Prevention
- Use built-in alphabet presets (!-u, z85) rather than custom alphabets.
- Verify exactly 85 unique characters before invoking.
- Check expandAlphRange output when using ranges.
When it happens
Trigger: Providing a custom alphabet shorter/longer than 85; an alphabet with duplicate characters; a range like A-Z that expands to fewer than expected; mixing presets.
Common situations: User edits the alphabet field and loses characters; confusion between the standard !-u range and the IPv6/z85 alphabets; copy-paste truncation.
Related errors
- The all-zero group char cannot appear in the alphabet
- Alphabet must be of length 58
- Unrecognised unit
- Error: Alphabet must be of length 85
- Invalid Base64 alphabet length (${alphabet.length}): ${alpha
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/5530436c62e2dde0.
Report an issue: GitHub.