scryptsy

build status Coverage Status Version

browser support

scryptsy is a pure Javascript implementation of the scrypt key derivation function that is fully compatible with Node.js and the browser (via Browserify).

Package Info

Why?

Scrypt is an integral part of many crypto currencies. It's a part of the BIP38 standard for encrypting private Bitcoin keys. It also serves as the proof-of-work system for many crypto currencies, most notably: Litecoin and Dogecoin.

Why didn't I just the predominant pure JavaScript imlementation found here? Because it's riddled with bugs, contains no tests, and is a transliteration of the Java version. i.e. it's neither Node.js optimized nor browser optimized. Required optimizations: Buffer in Node.js and type arrays in the browser.

Installation

npm install --save scryptsy

Example

var scrypt = require('scryptsy')

var key = "pleaseletmein"
var salt = "SodiumChloride"
var data = scrypt(key, salt, 16384, 8, 1, 64)
console.log(data.toString('hex')) 
// => 7023bdcb3afd7348461c06cd81fd38ebfda8fbba904f8e3ea9b543f6545da1f2d5432955613f0fcf62d49705242a9af9e61e85dc0d651e40dfcf017b45575887

API

scrypt(key, salt, N, r, p, keyLenBytes, [progressCallback])

Returns Buffer.

Resources

Credits

This code was modified from the code found here https://github.com/cheongwy/node-scrypt-js which was based on https://github.com/wg/scrypt.