gchq/CyberChef · error · OperationError
Error: Alphabet must be of length 85
Error message
Error: Alphabet must be of length 85
What it means
To Base85 requires an alphabet of exactly 85 unique characters (ASCII85/Z85 variants). The guard enforces both length === 85 and a unique count of 85 before encoding, since Base85 packs 4 bytes into 5 symbols and needs all 85 symbols available.
Source
Thrown at src/core/operations/ToBase85.mjs:57
}
];
}
/**
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
input = new Uint8Array(input);
const alphabet = Utils.expandAlphRange(args[0]).join(""),
encoding = alphabetName(alphabet),
includeDelim = args[1];
let result = "";
if (alphabet.length !== 85 ||
[].unique.call(alphabet).length !== 85) {
throw new OperationError("Error: Alphabet must be of length 85");
}
if (input.length === 0) return "";
let block;
for (let i = 0; i < input.length; i += 4) {
block = (
((input[i]) << 24) +
((input[i + 1] || 0) << 16) +
((input[i + 2] || 0) << 8) +
((input[i + 3] || 0))
) >>> 0;
if (encoding !== "Standard" || block > 0) {
let digits = [];
for (let j = 0; j < 5; j++) {
digits.push(block % 85);
block = Math.floor(block / 85);View on GitHub (pinned to 4290ea7539)
Solutions
- Use the standard ASCII85 alphabet (0-9, A-Z, a-z, plus !-u) or the Z85 set as appropriate.
- Verify the alphabet has exactly 85 distinct characters.
- Remove any duplicate or whitespace characters.
Example fix
// before: alphabet = "0-9A-Za-z!-u" mis-typed, <85 unique -> throws // after: alphabet = a valid 85-character ASCII85 set -> passes
Defensive patterns
Strategy: validation
Validate before calling
const set = new Set([...alphabet]);
if (alphabet.length !== 85 || set.size !== 85) {
throw new Error("Base85 alphabet must have 85 unique chars");
} Type guard
const isValidBase85Alphabet = a => a.length === 85 && new Set(a).size === 85;
Try / catch
try { toBase85(input, [alphabet, includeDelim]); }
catch (e) { if (/length 85/.test(e.message)) { alphabet = DEFAULT_BASE85; } else throw e; } Prevention
- Pick a documented Base85 variant (ASCII85 or Z85) and use its exact alphabet.
- Validate length and uniqueness before encoding.
- Avoid whitespace inside the alphabet string.
When it happens
Trigger: Changing the alphabet argument to fewer/more than 85 characters, or including duplicates, so either the length or uniqueness check fails.
Common situations: Swapping between ASCII85 and Z85 alphabets and mistyping one; pasting an alphabet with a stray space or missing character; using an expanded range that does not yield 85 unique symbols.
Related errors
- Error: alphabet must be of length 58
- Invalid Base64 alphabet length (${alphabet.length}): ${alpha
- Error: Base64 alphabet should be 64 characters long, or 65 w
- Byte length must be a positive integer
- Letter ${letter} is not included in LS47
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/6e4e9bcf90b22d2a.
Report an issue: GitHub.