npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

scrypt-async-modern

v3.0.12

Published

Fast "async" scrypt implementation in modern JavaScript.

Downloads

5,600

Readme

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

  • password: string or Array of bytes or Uint8Array
  • salt: string or Array of bytes or Uint8Array
  • options: object with key derivation options (see below)

Options:

  • N: CPU/memory cost parameter, must be power of two (default = 16384), alternatively you can specify logN where N = 2^logN
  • r: block size parameter (default = 8)
  • p: parallelization parameter (default = 1)
  • dkLen: derived key length (default = 32)
  • interruptStep: (optional) the amount of loop cycles to execute before the next setImmediate/setTimeout (defaults = 0)
  • encoding: (optional) result encoding 'base64' or 'hex' (result will be a string), 'binary' (result will be a Uint8Array) or undefined (result will be an Array of bytes, default).

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.