{"record":{"id":"90b470f09311e4a0","repo":"gchq/CyberChef","slug":"unknown-hash-input-type-inputtype","errorCode":null,"errorMessage":"Unknown hash input type: ${inputType}","messagePattern":"Unknown hash input type: (.+?)","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/GenerateAllHashes.mjs","lineNumber":153,"sourceCode":"     * @param {Function} algo - The hash or checksum algorithm\n     * @param {string} inputType\n     * @param {Object[]} [params=[]]\n     * @returns {string}\n     */\n    executeAlgo(algo, inputType, params=[]) {\n        let digest = null;\n        switch (inputType) {\n            case \"arrayBuffer\":\n                digest = algo.run(this.inputArrayBuffer, params);\n                break;\n            case \"str\":\n                digest = algo.run(this.inputStr, params);\n                break;\n            case \"byteArray\":\n                digest = algo.run(this.inputByteArray, params);\n                break;\n            default:\n                throw new OperationError(\"Unknown hash input type: \" + inputType);\n        }\n\n        return digest;\n    }\n\n    /**\n     * Formats the digest depending on user-specified arguments\n     * @param {string} digest\n     * @param {string} length\n     * @param {boolean} includeNames\n     * @param {string} name\n     * @returns {string}\n     */\n    formatDigest(digest, length, includeNames, name) {\n        if (length !== \"All\" && (digest.length * 4) !== parseInt(length, 10))\n            return \"\";\n\n        if (!includeNames)","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/GenerateAllHashes.mjs#L135-L171","documentation":"Thrown by GenerateAllHashes.executeAlgo when a registered hash's `inputType` is not one of \"arrayBuffer\", \"str\", or \"byteArray\". The operation iterates an internal `hashes` table where each entry declares which input form the underlying algorithm expects; an unknown type means that table was built incorrectly or an entry was added without a valid inputType. It is effectively an internal/programmer error, not a user-input error.","triggerScenarios":"Extending the `hashes`/`executeAlgo` mapping with a new hash but spelling inputType wrong (e.g. \"string\" instead of \"str\", \"ArrayBuffer\", \"byte-array\"); a stale fork where the table and the switch drifted out of sync; passing a malformed hash descriptor into the op.","commonSituations":"Contributing a new hash/checksum to CyberChef and forgetting the inputType enum; running a modified build where a hash entry's inputType field was renamed.","solutions":["If you forked/extended the op, set the hash entry's inputType to exactly \"arrayBuffer\", \"str\", or \"byteArray\".","Add the new type as a switch case in executeAlgo if a genuinely new input form is required.","Re-sync with upstream if the table was edited locally.","File/track the issue against the operation rather than treating it as user data."],"exampleFix":"// before\nthis.hashes.push({ name: \"MyHash\", algo: MyHash, inputType: \"string\", params: [] });\n// after\nthis.hashes.push({ name: \"MyHash\", algo: MyHash, inputType: \"str\", params: [] });","handlingStrategy":"validation","validationCode":"const VALID_INPUT_TYPES = [\"arrayBuffer\", \"str\", \"byteArray\"];\nif (!VALID_INPUT_TYPES.includes(entry.inputType)) {\n  throw new Error(`Bad hash inputType ${JSON.stringify(entry.inputType)}; valid: ${VALID_INPUT_TYPES.join(\", \")}`);\n}","typeGuard":"/** @param {string} t */\nfunction isHashInputType(t){return[\"arrayBuffer\",\"str\",\"byteArray\"].includes(t);}","tryCatchPattern":null,"preventionTips":["When adding a hash entry, set inputType to exactly \"arrayBuffer\", \"str\", or \"byteArray\".","Add a matching switch case if introducing a new input form.","Keep the hashes table and executeAlgo switch in sync; this error indicates drift."],"tags":["hash","checksum","internal","argument-validation"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}