gchq/CyberChef · error · OperationError

No key entered

Error message

No key entered

What it means

Thrown by 'Vigenere Encode' when the key argument (args[0]) lowercased is the empty string. Same rationale as decode: the per-character shift needs a non-empty alphabetic key, and an empty key would break the modular indexing into key.length.

Source

Thrown at src/core/operations/VigenèreEncode.mjs:50

            }
        ];
    }

    /**
     * @param {string} input
     * @param {Object[]} args
     * @returns {string}
     */
    run(input, args) {
        const alphabet = "abcdefghijklmnopqrstuvwxyz",
            key = args[0].toLowerCase();
        let output = "",
            fail = 0,
            keyIndex,
            msgIndex,
            chr;

        if (!key) throw new OperationError("No key entered");
        if (!/^[a-zA-Z]+$/.test(key)) throw new OperationError("The key must consist only of letters");

        for (let i = 0; i < input.length; i++) {
            if (alphabet.indexOf(input[i]) >= 0) {
                // Get the corresponding character of key for the current letter, accounting
                // for chars not in alphabet
                chr = key[(i - fail) % key.length];
                // Get the location in the vigenere square of the key char
                keyIndex = alphabet.indexOf(chr);
                // Get the location in the vigenere square of the message char
                msgIndex = alphabet.indexOf(input[i]);
                // Get the encoded letter by finding the sum of indexes modulo 26 and finding
                // the letter corresponding to that
                output += alphabet[(keyIndex + msgIndex) % 26];
            } else if (alphabet.indexOf(input[i].toLowerCase()) >= 0) {
                chr = key[(i - fail) % key.length].toLowerCase();
                keyIndex = alphabet.indexOf(chr);
                msgIndex = alphabet.indexOf(input[i].toLowerCase());

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Provide a non-empty, letters-only key.
  2. Verify recipe JSON carries a non-empty key value.
  3. Generate a random alphabetic key if one is needed rather than leaving blank.

Example fix

// before
vigenereEncode(plaintext, "");
// after
vigenereEncode(plaintext, "LEMON");
Defensive patterns

Strategy: validation

Validate before calling

const key = String(args[0] ?? "").toLowerCase();
if (key === "") throw new Error("Vigenere key must not be empty");
if (!/^[a-z]+$/.test(key)) throw new Error("Vigenere key must be letters only");

Type guard

function isValidVigenereKey(k) { const s = String(k ?? "").toLowerCase(); return s !== "" && /^[a-z]+$/.test(s); }

Prevention

When it happens

Trigger: Empty key field, empty string passed programmatically, or a recipe with a blank key. The empty check runs before the letters-only validation.

Common situations: Cleared key field, imported recipe missing the key, or building a recipe programmatically and forgetting to set the key.

Related errors


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