The scrypt password-based key derivation function with sync and cancellable async.
Overall
score
98%
A utility module that derives cryptographic keys from passwords using a computationally expensive key derivation function. The module should accept a password and salt, perform synchronous key derivation with specified parameters, and return the derived key as a byte array.
[112, 97, 115, 115] (representing "pass"), salt array [115, 97, 108, 116] (representing "salt"), N=1024, r=8, p=1, and dkLen=32, it returns a 32-byte derived key as a Uint8Array @test@generates
/**
* Derives a cryptographic key from a password using scrypt algorithm (synchronous).
*
* @param {Array<number>|Uint8Array} password - The password as an array of bytes (0-255)
* @param {Array<number>|Uint8Array} salt - The salt as an array of bytes (0-255)
* @param {number} N - CPU/memory cost parameter (must be power of 2)
* @param {number} r - Block size parameter
* @param {number} p - Parallelization parameter
* @param {number} dkLen - Desired length of derived key in bytes
* @returns {Uint8Array} The derived key
* @throws {Error} If parameters are invalid
*/
function deriveKey(password, salt, N, r, p, dkLen) {
// IMPLEMENTATION HERE
}
module.exports = { deriveKey };Provides password-based key derivation functionality.
Install with Tessl CLI
npx tessl i tessl/npm-scrypt-jsdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10