Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

scrypt.js

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scrypt.js

Scrypt in Node.js and in the browser. Fast & simple.

  • 0.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6.5K
increased by27.16%
Maintainers
1
Weekly downloads
 
Created
Source

scrypt.js

This purpose of this library is to provide a single interface to both a C and a pure Javascript based scrypt implementation. Supports browserify and will select the best option when running under Node or in the browser.

It is using the following two underlying implementations:

  • scryptsy for the pure Javascript implementation
  • scrypt for the C version

It only supports hashing. Doesn't offer an async option and doesn't implement the HMAC format. If you are looking for those, please use the Node scrypt library.

API

There is only one method returned for hashing using scrypt. All parameters are mandatory except the progress callback:

  • key - The key/passphrase. Although it accepts a String, please use a Buffer to avoid problems later.
  • salt - The salt. Same as with the key, please try to use a Buffer.
  • n - Iteration count.
  • r - Block size for the underlying hash.
  • p - Parallelization factor.
  • dklen - The derived key length aka. output size.

Example usage

// Load default implementation
var scrypt = require('scrypt.js')

// Load specific version
var scrypt = require('scrypt.js/js') // pure Javascript
var scrypt = require('scrypt.js/node') // C on Node

scrypt(key, salt, n, r, p, dklen, progressCb) // returns Buffer

The progress callback

This callback (progressCb in the above example) is not available on Node.

Every 1000 iterations it will return an object with the following properties:

  • current - Current iteration number.
  • total - Total iterations.
  • percent - Progress in percentage (double).

Other scrypt implementations

Keywords

FAQs

Package last updated on 18 Dec 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc