The scrypt password-based key derivation function with sync and cancellable async.
Overall
score
98%
Build a secure key storage system that derives cryptographic keys from user passwords and stores them in a standardized binary format.
The system should provide functionality to:
Create a module that exports the following functions:
deriveKey(password, salt, keyLength) - Derives a cryptographic key from the given password and salt, returning it as a byte array. The keyLength parameter specifies the desired key length in bytes (16, 32, or 64).keyToHex(keyBytes) - Converts a byte array key to a hexadecimal string representation.isValidKeyFormat(key) - Checks if a key is in valid byte array format (should be a Uint8Array).Use standard scrypt parameters for key derivation:
@generates
/**
* Derives a cryptographic key from a password and salt
* @param {string} password - The password string
* @param {string} salt - The salt string
* @param {number} keyLength - Desired key length in bytes (16, 32, or 64)
* @returns {Promise<Uint8Array>} The derived key as a Uint8Array
*/
async function deriveKey(password, salt, keyLength) {
// Implementation here
}
/**
* Converts a Uint8Array key to hexadecimal string
* @param {Uint8Array} keyBytes - The key as byte array
* @returns {string} Hexadecimal representation
*/
function keyToHex(keyBytes) {
// Implementation here
}
/**
* Validates that a key is in correct Uint8Array format
* @param {*} key - The key to validate
* @returns {boolean} True if key is a Uint8Array
*/
function isValidKeyFormat(key) {
// Implementation here
}
module.exports = {
deriveKey,
keyToHex,
isValidKeyFormat
};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