Parameters
Returns
Promise<string>
The key derived from the password.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
function scrypt(
_passwd,
_salt,
N,
r,
p,
dkLen,
progress?): Promise<string>
| Parameter | Type | Description |
|---|---|---|
_passwd | BytesLike | The password to use. |
_salt | BytesLike | The salt to use. |
N | number | The CPU/memory cost parameter. |
r | number | The block size parameter. |
p | number | The parallelization parameter. |
dkLen | number | The length of the key to generate. |
progress? | ProgressCallback | A callback to update the progress. |
Promise<string>
The key derived from the password.
// The password must be converted to bytes, and it is generally
// best practices to ensure the string has been normalized. Many
// formats explicitly indicate the normalization form to use.
password = 'hello';
passwordBytes = toUtf8Bytes(password, 'NFKC');
salt = id('some-salt');
// Compute the scrypt
scrypt(passwordBytes, salt, 1024, 8, 1, 16);
Was this page helpful?
