gchq/CyberChef · error · OperationError

The key must consist only of letters in the English alphabet

Error message

The key must consist only of letters in the English alphabet

What it means

Thrown by BifidCipherDecode.run when the keyword, after uppercasing and J->I substitution, contains any character outside A-Z AND is non-empty. The Bifid cipher builds a 5x5 Polybius square from the keyword, so the keyword must be pure English letters (I/J merged). An empty keyword is allowed (defaults to the standard square). The check is /^[A-Z]+$/ on the uppercased keyword string, so digits, spaces, punctuation, and accented letters all trigger rejection.

Source

Thrown at src/core/operations/BifidCipherDecode.mjs:55

    /**
     * @param {string} input
     * @param {Object[]} args
     * @returns {string}
     *
     * @throws {OperationError} if invalid key
     */
    run(input, args) {
        const keywordStr = args[0].toUpperCase().replace("J", "I"),
            keyword = keywordStr.split("").unique(),
            alpha = "ABCDEFGHIKLMNOPQRSTUVWXYZ",
            structure = [];

        let output = "",
            count = 0,
            trans = "";

        if (!/^[A-Z]+$/.test(keywordStr) && keyword.length > 0)
            throw new OperationError("The key must consist only of letters in the English alphabet");

        const polybius = genPolybiusSquare(keywordStr);

        input.replace("J", "I").split("").forEach((letter) => {
            const alpInd = alpha.split("").indexOf(letter.toLocaleUpperCase()) >= 0;
            let polInd;

            if (alpInd) {
                for (let i = 0; i < 5; i++) {
                    polInd = polybius[i].indexOf(letter.toLocaleUpperCase());
                    if (polInd >= 0) {
                        trans += `${i}${polInd}`;
                    }
                }

                if (alpha.split("").indexOf(letter) >= 0) {
                    structure.push(true);
                } else if (alpInd) {

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Use a keyword containing only English letters A-Z (spaces/punctuation are not stripped).
  2. Strip or replace non-A-Z characters before setting the keyword.
  3. Leave the keyword empty to use the default ABCDE... Polybius square.

Example fix

// before
chef.bifidCipherDecode(input, { keyword: "MY-KEY 2" });

// after
chef.bifidCipherDecode(input, { keyword: "MYKEY" });
Defensive patterns

Strategy: validation

Validate before calling

function assertBifidKeyword(keyword) {
  const kw = String(keyword).toUpperCase();
  if (kw.length > 0 && !/^[A-Z]+$/.test(kw)) {
    throw new Error("Bifid keyword must contain only English letters A-Z");
  }
  return kw;
}
assertBifidKeyword(keyword);

Type guard

function isAlphaKeyword(s) {
  const kw = String(s ?? "").toUpperCase();
  return kw.length === 0 || /^[A-Z]+$/.test(kw);
}

Prevention

When it happens

Trigger: Supplying a keyword with spaces, hyphens, digits (e.g. 'KEY 2'), accented characters (e.g. 'CAFE'), punctuation, or mixed scripts. Note: because J is replaced by I first, a literal 'J' in the keyword passes the check.

Common situations: User includes a space or hyphen thinking it is ignored; passphrase contains a digit; non-English accent characters in the keyword.

Related errors


AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13). Data as JSON: /api/errors/0b011c5b9747deac. Report an issue: GitHub.