gchq/CyberChef · error · OperationError

Unrecognised unit

Error message

Unrecognised unit

What it means

Thrown by WindowsFiletimeToUNIXTimestamp.run after subtracting the 1601→1970 epoch offset (116444736000000000). The operation must divide/multiply the resulting 100-nanosecond count into the requested precision, so it only recognises four exact unit strings: 'Seconds (s)', 'Milliseconds (ms)', 'Microseconds (μs)', 'Nanoseconds (ns)'. Any other value for args[0] ('Output units') falls into the trailing else and aborts before producing a timestamp.

Source

Thrown at src/core/operations/WindowsFiletimeToUNIXTimestamp.mjs:82

        if (format.startsWith("Hex")) {
            input = new BigNumber(input, 16);
        } else {
            input = new BigNumber(input);
        }

        input = input.minus(new BigNumber("116444736000000000"));

        if (units === "Seconds (s)") {
            input = input.dividedBy(new BigNumber("10000000"));
        } else if (units === "Milliseconds (ms)") {
            input = input.dividedBy(new BigNumber("10000"));
        } else if (units === "Microseconds (μs)") {
            input = input.dividedBy(new BigNumber("10"));
        } else if (units === "Nanoseconds (ns)") {
            input = input.multipliedBy(new BigNumber("100"));
        } else {
            throw new OperationError("Unrecognised unit");
        }

        return input.toFixed();
    }

}

export default WindowsFiletimeToUNIXTimestamp;

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Set args[0] to one of the four exact canonical strings the constructor lists: 'Seconds (s)', 'Milliseconds (ms)', 'Microseconds (μs)', 'Nanoseconds (ns) — including the parenthesised suffix and, for microseconds, the μ character.
  2. If you imported a recipe/config, re-export it from the current CyberChef build so the unit label matches the installed version.
  3. Avoid mutating the units argument manually; build the opList from the operation's own args metadata rather than hard-coding the string.

Example fix

// before
chef.bake(input, [{op:"Windows Filetime to UNIX Timestamp", args:["ms","Decimal"]}]);
// after
chef.bake(input, [{op:"Windows Filetime to UNIX Timestamp", args:["Milliseconds (ms)","Decimal"]}]);
Defensive patterns

Strategy: validation

Validate before calling

const VALID_UNITS = ["Seconds (s)","Milliseconds (ms)","Microseconds (μs)","Nanoseconds (ns)"];
function buildFiletimeRecipe(units, format="Decimal") {
  if (!VALID_UNITS.includes(units)) throw new Error(`units must be one of ${VALID_UNITS.join(", ")}`);
  return [{op:"Windows Filetime to UNIX Timestamp", args:[units, format]}];
}

Type guard

const isFiletimeUnit = (u) => ["Seconds (s)","Milliseconds (ms)","Microseconds (μs)","Nanoseconds (ns)"].includes(u);

Try / catch

try { result = chef.bake(input, recipe); } catch (e) { if (/Unrecognised unit/.test(e.message)) { /* fix units arg */ } else throw e; }

Prevention

When it happens

Trigger: The 'Output units' argument is set to a string not in the option list. In the UI this is prevented by a dropdown, so the error only appears when a recipe/config is built programmatically (Node API chef.bake, imported .chr recipe JSON, or a hand-edited opList) with a typo'd or localised unit string.

Common situations: Copying a recipe JSON between CyberChef versions or forks where the unit labels differ; feeding an opList built by another tool; passing a raw value like 'ms' or 'Seconds' instead of the full canonical 'Milliseconds (ms)' / 'Seconds (s)'.

Related errors


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