gchq/CyberChef · error · OperationError
Error: Radix argument must be between 2 and 36
Error message
Error: Radix argument must be between 2 and 36
What it means
Thrown by the Luhn Checksum operation when the 'Radix' argument (args[0]) is outside the inclusive range 2–36. JavaScript's parseInt only supports radix 2–36, and the Luhn mod-N algorithm needs at least base 2, so run() rejects any other value at LuhnChecksum.mjs:77 with an OperationError. This check runs before any input is processed.
Source
Thrown at src/core/operations/LuhnChecksum.mjs:77
}
even = !even;
return acc + temp;
}, 0) % radix; // Use radix as the modulus base
}
/**
* @param {string} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
if (!input) return "";
const radix = args[0];
if (radix < 2 || radix > 36) {
throw new OperationError("Error: Radix argument must be between 2 and 36");
}
if (radix % 2 !== 0) {
throw new OperationError("Error: Radix argument must be divisible by 2");
}
const checkSum = this.checksum(input, radix).toString(radix);
let checkDigit = this.checksum(input + "0", radix);
checkDigit = checkDigit === 0 ? 0 : (radix - checkDigit);
checkDigit = checkDigit.toString(radix);
return `Checksum: ${checkSum}
Checkdigit: ${checkDigit}
Luhn Validated String: ${input + "" + checkDigit}`;
}
}
View on GitHub (pinned to 4290ea7539)
Solutions
- Set Radix to an even integer between 2 and 36 inclusive (10 for classic Luhn, 36 for full alphanumeric).
- If loading a recipe, clamp/validate the radix field before running.
- For bases above 36, use a different operation — Luhn Checksum cannot represent them.
Example fix
// before luhn.run(input, [64]); // out of range // after luhn.run(input, [36]); // valid even radix within 2..36
Defensive patterns
Strategy: validation
Validate before calling
function validLuhnRadix(r) {
return Number.isInteger(r) && r >= 2 && r <= 36 && r % 2 === 0;
}
if (!validLuhnRadix(radix)) {
throw new Error('Radix must be an even integer between 2 and 36');
} Type guard
function isLuhnRadix(v: unknown): v is number {
return typeof v === 'number' && Number.isInteger(v) && v >= 2 && v <= 36 && v % 2 === 0;
} Prevention
- Clamp/validate radix at recipe build time.
- Default to 10 for numeric Luhn or 36 for alphanumeric.
- Reject odd or out-of-range values before invoking the op.
When it happens
Trigger: Setting the Radix argument to a number less than 2 or greater than 36 — e.g. 0, 1, 37, 64, or a negative value. Triggered at LuhnChecksum.mjs:76-78 before checksum() is called.
Common situations: Default value edited to an out-of-range number; a recipe JSON carrying a stale/invalid radix; confusing the radix with a modulo or checksum length; passing a base-64 expectation (not supported — max is 36).
Related errors
- Character: ${elem} is not valid in radix ${radix}.
- Error: Radix argument must be divisible by 2
- Invalid custom CRC arguments
- Unknown checksum algorithm
- Size must be between 0 and 512
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/df87d42ca306a6c3.
Report an issue: GitHub.