gchq/CyberChef · error · OperationError
Error: Base argument must be between 2 and 36
Error message
Error: Base argument must be between 2 and 36
What it means
Thrown by From Charcode when the Base argument is outside 2-36. The operation uses parseInt(bites[i], base), which only accepts bases in that range. The check runs before parsing any character codes, so it fires regardless of input content. This mirrors the From Base radix constraint.
Solutions
- Set the Base arg to a supported value (commonly 16 for hex, 10 for decimal).
- For Base64 text, use the From Base64 operation instead.
- Validate the base in calling code before invoking.
Example fix
// before: base 64 (not supported) fromCharcode.run(input, ['Space', 64]) // throws // after: base 16 for hex charcodes fromCharcode.run(input, ['Space', 16])
Defensive patterns
Strategy: validation
Validate before calling
const base = args[1];
if (base < 2 || base > 36) {
// clamp/fix the base; do not call fromCharcode.run()
} Type guard
function isValidCharcodeBase(b) {
return Number.isInteger(b) && b >= 2 && b <= 36;
} Try / catch
try {
fromCharcode.run(input, args);
} catch (e) {
if (e.type === 'OperationError' && /Base argument must be between/.test(e.message)) {
// set Base to 16 (hex) or 10 (decimal); use From Base64 for base-64
} else throw e;
} Prevention
- Constrain the Base UI input to 2-36.
- Use From Base64 for Base64-encoded text, not this op.
- Validate programmatically-supplied base values.
When it happens
Trigger: Setting the Base arg below 2 or above 36; passing 0, 1, or 64; a recipe configured for base-64 charcodes (which is not supported here).
Common situations: Confusing charcode base with Base64 encoding; typo in the Base field; programmatic recipe with an unvalidated base value.
Related errors
- Error: Radix argument must be between 2 and 36
- Bit length must be at least 2
- Error: Base argument must be between 2 and 36
- Length must be greater than 0
- Ψ1 custom lugs must be 43 long and can only include . or x
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/fa9868eae757930d.
Report an issue: GitHub.
Appendix: source
Thrown at src/core/operations/FromCharcode.mjs:58
}
];
}
/**
* @param {string} input
* @param {Object[]} args
* @returns {ArrayBuffer}
*
* @throws {OperationError} if base out of range
*/
run(input, args) {
const delim = Utils.charRep(args[0] || "Space"),
base = args[1];
let bites = input.split(delim),
i = 0;
if (base < 2 || base > 36) {
throw new OperationError("Error: Base argument must be between 2 and 36");
}
if (input.length === 0) {
return new ArrayBuffer;
}
if (base !== 16 && isWorkerEnvironment()) self.setOption("attemptHighlight", false);
// Split into groups of 2 if the whole string is concatenated and
// too long to be a single character
if (bites.length === 1 && input.length > 17) {
bites = [];
for (i = 0; i < input.length; i += 2) {
bites.push(input.slice(i, i+2));
}
}
let latin1 = "";View on GitHub (pinned to 4290ea7539)