1.1.1 • Published 1 year ago

scrypt-mcf v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

License: MIT Contributor Covenant JavaScript Style Guide Node.js CI Coverage Status

scrypt-mcf

A scrypt implementation for both Browsers and Node.js using Modular Crypt Format (MCF) and/or PHC String Format. Same as in pch-scrypt, scrypt-mcf generates scrypt “hashes” in the following format:

$scrypt$ln=<cost>,r=<blocksize>,p=<parallelism>$<salt in base64 no padding>$<hash in base64 no padding>

Usage

scrypt-mcf can be imported to your project with npm:

npm install scrypt-mcf

Then either require (Node.js CJS):

const scryptMcf = require('scrypt-mcf')

or import (JavaScript ES module):

import * as scryptMcf from 'scrypt-mcf'

The appropriate version for browser or node is automatically exported.

You can also download the IIFE bundle, the ESM bundle or the UMD bundle and manually add it to your project, or, if you have already installed scrypt-mcf in your project, just get the bundles from node_modules/scrypt-mcf/dist/bundles/.

An example of usage could be:

import { hash, verify } from 'scrypt-mcf'

async function main () {
  const mcfString = await hash('MyPassword') // $scrypt$ln=17,r=8,p=1$bjDYMlHNovhjawrXbfrAdw$q7Z6sgaMJMMdSNECL+MGGWX+6Vm+q/o6ysACeY8eYNY
  let passwordMatch = await verify('MyPassword', mcfString) // true
  passwordMatch = await verify('OtherPassword', mcfString) // false

  // You can also use non-default options
  const mcfString2 = await hash('MyPassword', { derivedKeyLength: 64, scryptParams: { logN: 18, r: 8, p: 2 } }) // $scrypt$ln=18,r=8,p=2$9lRqxeVS/at1bktaJ5q64A$pFmlWRrddcMHScP1Yceyo6UKc8eKEJDv+/aWSRlArg3b4Hu+xEFE88P+0HHilbBViRAAhtNWETTosUtxEJl95g
  passwordMatch = await verify('MyPassword', mcfString) // true
  passwordMatch = await verify('OtherPassword', mcfString) // false
}

main()

API reference documentation

Check the API

1.1.1

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago