gchq/CyberChef · error · OperationError
${val} is not a base92 character
Error message
${val} is not a base92 character What it means
Thrown by base92Ord(val) in src/core/lib/Base92.mjs:42 when the input character is not part of the Base92 alphabet recognised by this library ('!', '#'..'_', 'a'..'}'). The function walks three branches and only throws on exhaustion, so any character outside those three ranges — including space, double-quote, backtick, tilde, control chars, or any uppercase letter — is rejected.
Source
Thrown at src/core/lib/Base92.mjs:42
return "#".charCodeAt(0) + val - 1;
else
return "a".charCodeAt(0) + val - 62;
}
/**
* Base92 alphabet ord
*
* @param {string} val
* @returns {number}
*/
export function base92Ord(val) {
if (val === "!")
return 0;
else if ("#" <= val && val <= "_")
return val.charCodeAt(0) - "#".charCodeAt(0) + 1;
else if ("a" <= val && val <= "}")
return val.charCodeAt(0) - "a".charCodeAt(0) + 62;
throw new OperationError(`${val} is not a base92 character`);
}
View on GitHub (pinned to 4290ea7539)
Solutions
- Pre-filter the input to the accepted alphabet: s.replace(/[^!#-_a-}]/g, '').
- Confirm the source used the same Base92 dialect as this library before decoding.
- Trim whitespace and newlines from pasted input.
- Wrap decoding in try/catch and report the offending character to the user.
Example fix
// before - uppercase 'A' is not in this Base92 alphabet
const v = base92Ord('A');
// after - strip characters outside the accepted ranges first
const cleaned = input.replace(/[^!#-_a-}]/g, '');
const v = base92Ord(cleaned[i]); Defensive patterns
Strategy: validation
Validate before calling
function cleanBase92(s) {
return s.replace(/[^!#-_a-}]/g, '');
}
// then decode(cleanBase92(input)) Type guard
function isBase92AlphabetChar(ch) {
return typeof ch === 'string' && ch.length === 1 && /^[!#\-_a-}]$/.test(ch);
} Try / catch
try {
const val = base92Ord(ch);
} catch (e) {
if (e instanceof OperationError && /not a base92 character/.test(e.message)) {
// skip or substitute the offending character
}
} Prevention
- Confirm the source used the same Base92 alphabet dialect as this library.
- Strip whitespace, uppercase, and control characters before decoding.
- Wrap the decode loop to collect and report all bad characters at once.
When it happens
Trigger: Direct call base92Ord(' '), base92Ord('A'), base92Ord('~'), base92Ord(''). Indirectly: decoding a string that contains whitespace, uppercase, or characters from a different Base92 variant (there are several incompatible Base92 definitions) using this library's decoder.
Common situations: Decoding Base92 produced by a different implementation with a different alphabet ordering; copy-paste that introduced spaces or newlines; mixed-case input where uppercase letters are not in this alphabet; treating arbitrary ASCII as Base92.
Related errors
- Error: Base64 input contains non-alphabet char(s)
- Error: Base64 alphabet should be 64 characters long, or 65 w
- Error: Invalid Base64 input length (${data.length}). Cannot
- Error: Base64 padding character (${pad}) not used in the cor
- Error: Base64 not padded to a multiple of 4.
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/8ec55ddc48c7a1bf.
Report an issue: GitHub.