gchq/CyberChef · error · OperationError

Incorrect number of samples.

Error message

Incorrect number of samples.

What it means

Compare SSDEEP Hashes compares two ssdeep fuzzy hashes and returns a 0–100 similarity score. It splits the input on the chosen delimiter (Utils.charRep(args[0])) and requires exactly two samples, since ssdeepjs.similarity needs exactly two operands. The guard `if (samples.length !== 2)` rejects any other count.

Source

Thrown at src/core/operations/CompareSSDEEPHashes.mjs:46

        this.inputType = "string";
        this.outputType = "Number";
        this.args = [
            {
                "name": "Delimiter",
                "type": "option",
                "value": HASH_DELIM_OPTIONS
            }
        ];
    }

    /**
     * @param {string} input
     * @param {Object[]} args
     * @returns {Number}
     */
    run(input, args) {
        const samples = input.split(Utils.charRep(args[0]));
        if (samples.length !== 2) throw new OperationError("Incorrect number of samples.");
        return ssdeepjs.similarity(samples[0], samples[1]);
    }

}

export default CompareSSDEEPHashes;

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Provide exactly two ssdeep hashes separated by exactly one occurrence of the selected delimiter.
  2. Match the delimiter option to the real separator in your input.
  3. Strip whitespace and surplus delimiters so the split produces exactly two non-empty samples.

Example fix

// before (only one ssdeep hash)
input = "3:AXhF:AXhF";
// after (two hashes separated by a comma, delimiter = Comma)
input = "3:AXhF:AXhF,24:ABCD:ABCD";
Defensive patterns

Strategy: validation

Validate before calling

import Utils from "src/core/Utils.mjs";
const delim = Utils.charRep(delimiterOption);
const samples = input.split(delim);
if (samples.length !== 2) {
  throw new Error(`Expected exactly 2 ssdeep hashes, got ${samples.length}`);
}
return samples;

Type guard

function isTwoSamples(input, delim) {
  return input.split(delim).length === 2;
}

Prevention

When it happens

Trigger: Input yielding zero, one, or three+ samples after splitting; mismatched delimiter vs. the actual separator; empty input; extra delimiters creating empty fields.

Common situations: Pasting a single ssdeep hash; concatenating more than two; choosing the wrong delimiter option; ssdeep hash strings internally containing the chosen delimiter.

Related errors


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