scrypt-async-modern npm version

Fast “async” scrypt implementation in modern JavaScript.

Works in browsers without throwing “kill slow script” warnings due to configurable interruptStep, which yields from calculation. Also works with Node.js (but you should really use the C implementation for that).

Installation

Yarn:

$ yarn add scrypt-async-modern

NPM:

$ npm install scrypt-async-modern

To improve performance with small interruptStep values, use setImmediate shim, such as https://github.com/YuzuJS/setImmediate.

Usage

scrypt(password, salt, options): Promise

Derives a key from password and salt and fulfills a Promise with the derived key as the only argument.

If options.interruptStep is set, calculations are interrupted with setImmediate (or zero setTimeout) at the given interruptSteps to avoid freezing the browser. If it’s not set or set to zero, the callback is called immediately after the calculation, avoiding setImmediate.

Arguments

Options:

Example:

const derivedKey = await scrypt("mypassword", "saltysalt", {
  N: 16384,
  r: 8,
  p: 1,
  dkLen: 16,
  encoding: "hex"
});

console.log(derivedKey); // "5012b74fca8ec8a4a0a62ffdeeee959d"

Notes

Fork of dchest/scrypt-async-js.

MIT license.