{"record":{"id":"7a87d74dc3983c9b","repo":"gchq/CyberChef","slug":"error-err","errorCode":null,"errorMessage":"Error: ${err}","messagePattern":"Error: (.+?)","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/Scrypt.mjs","lineNumber":84,"sourceCode":"        const salt = Buffer.from(Utils.convertToByteArray(args[0].string || \"\", args[0].option)),\n            iterations = args[1],\n            memFactor = args[2],\n            parallelFactor = args[3],\n            keyLength = args[4];\n\n        try {\n            const data = scryptsy(\n                input, salt, iterations, memFactor, parallelFactor, keyLength,\n                p => {\n                    // Progress callback\n                    if (isWorkerEnvironment())\n                        self.sendStatusMessage(`Progress: ${p.percent.toFixed(0)}%`);\n                }\n            );\n\n            return data.toString(\"hex\");\n        } catch (err) {\n            throw new OperationError(\"Error: \" + err.toString());\n        }\n    }\n\n}\n\nexport default Scrypt;\n","sourceCodeStart":66,"sourceCodeEnd":91,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/Scrypt.mjs#L66-L91","documentation":"Thrown by the Scrypt operation as a catch-all wrapper around the scryptsy library. Any exception from scryptsy — most commonly invalid parameters (N must be a power of two, N/r/p too large) or out-of-memory conditions — is caught and re-thrown as an OperationError with the original message.","triggerScenarios":"Calling Scrypt with an N (iterations) value that is not a power of two, or N/r/p combinations whose memory footprint (128 * N * r bytes) exceeds available memory. Empty input or salt edge cases can also surface here depending on scryptsy version.","commonSituations":"Setting N=10000 (not a power of two); very large N (e.g. 2^20) combined with r=8 exhausting worker heap; negative or zero key length; a salt toggle mismatch producing unexpected bytes.","solutions":["Read the embedded 'err' message — scryptsy states which parameter is invalid.","Ensure N (Iterations) is a power of two (e.g. 16384 = 2^14); start low and increase.","Reduce r or p if memory is the constraint; memory is roughly 128*N*r bytes.","Keep key length positive (default 64)."],"exampleFix":"// before\nscrypt.run(\"password\", [{string:\"salt\",option:\"UTF8\"}, 10000, 8, 1, 64])\n// after — N must be a power of two\nscrypt.run(\"password\", [{string:\"salt\",option:\"UTF8\"}, 16384, 8, 1, 64])","handlingStrategy":"validation","validationCode":"function validateScryptParams(N, r, p, keyLen) {\n  if (!Number.isInteger(N) || N < 2 || (N & (N - 1)) !== 0) {\n    throw new Error(\"N must be a power of two >= 2\");\n  }\n  if (r <= 0 || p <= 0 || keyLen <= 0) {\n    throw new Error(\"r, p, and keyLength must be positive\");\n  }\n  const approxBytes = 128 * N * r;\n  if (approxBytes > 256 * 1024 * 1024) {\n    throw new Error(`N*r too large (~${approxBytes} bytes); reduce N or r`);\n  }\n}","typeGuard":"function isScryptPowerOfTwo(N) { return Number.isInteger(N) && N >= 2 && (N & (N - 1)) === 0; }","tryCatchPattern":"try {\n  const data = scryptsy(input, salt, N, r, p, keyLen, cb);\n} catch (err) {\n  throw new OperationError(\"Error: \" + err.toString());\n}","preventionTips":["Always make N a power of two (e.g. 16384).","Estimate memory as 128*N*r bytes and keep it within the runtime's heap.","Start with conservative parameters and increase while testing."],"tags":["crypto","scrypt","kdf","operation"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}