function scryptSync
Usage in Deno
import { scryptSync } from "node:crypto";
scryptSync(): Buffer
Provides a synchronous scrypt implementation. Scrypt is a password-based key derivation function that is designed to be expensive computationally and memory-wise in order to make brute-force attacks unrewarding.
The salt
should be as unique as possible. It is recommended that a salt is
random and at least 16 bytes long. See NIST SP 800-132 for details.
When passing strings for password
or salt
, please consider caveats when using strings as inputs to cryptographic APIs
.
An exception is thrown when key derivation fails, otherwise the derived key is
returned as a Buffer
.
An exception is thrown when any of the input arguments specify invalid values or types.
const {
scryptSync,
} = await import('node:crypto');
// Using the factory defaults.
const key1 = scryptSync('password', 'salt', 64);
console.log(key1.toString('hex')); // '3745e48...08d59ae'
// Using a custom N parameter. Must be a power of two.
const key2 = scryptSync('password', 'salt', 64, { N: 1024 });
console.log(key2.toString('hex')); // '3745e48...aa39b34'
Buffer