gchq/CyberChef · error · OperationError

No key entered

Error message

No key entered

What it means

Thrown by 'Vigenere Decode' when the key argument (args[0]) lowercased is the empty string. A Vigenere cipher requires a non-empty alphabetic key to determine the shift per character; an empty key would cause division-by-zero in the modular key indexing.

Source

Thrown at src/core/operations/VigenèreDecode.mjs:49

            }
        ];
    }

    /**
     * @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) {
                chr = key[(i - fail) % key.length];
                keyIndex = alphabet.indexOf(chr);
                msgIndex = alphabet.indexOf(input[i]);
                // Subtract indexes from each other, add 26 just in case the value is negative,
                // modulo to remove if necessary
                output += alphabet[(msgIndex - keyIndex + alphabet.length) % 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());
                output += alphabet[(msgIndex + alphabet.length - keyIndex) % 26].toUpperCase();
            } else {
                output += input[i];
                fail++;

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Enter a non-empty key consisting only of letters (a-z, A-Z).
  2. Check imported recipe JSON for a missing/blank key field.
  3. If you do not know the key, brute-force/analyse the ciphertext rather than leaving the key blank.

Example fix

// before
vigenereDecode(ciphertext, "");
// after
vigenereDecode(ciphertext, "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: Leaving the key field empty, passing an empty string, or loading a recipe where the key was not saved. The empty-key check precedes the letters-only check.

Common situations: User clears the key field, or a recipe is shared/imported without the key value.

Related errors


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