emavola / credential-plus-argon2

🛡 argon2 plugin for credential-plus

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

credential-plus-argon2

Travis CI Codecov npm npm version npm dependencies npm dev dependencies

🛡 argon2 plugin for credential-plus

This package is thought to be used in conjunction with credential-plus

If you find a security flaw in this code, please report it.

Install

$ npm install --save credential-plus-argon2

Usage

const credential = require('credential-plus');
credential.install(require('credential-plus-argon2'));

// Hash and verify with argon2 and default configs
credential.hash('We are all unicorns', {func: 'argon2'}, (err, hash) => {
  console.log(hash);
  //=> {"hash":"$argon2d$v=19$m=4096,t=3,p=1$i5VhaDYfYqSWWoG1uKVBbw$QHpzhFRYJZwIcogtSciXh0hbc8f91PyGBdtWSNocuiE","func":"argon2"}
  credential.verify(hash, 'We are all unicorns', (match) =>{
    console.log(match);
    //=> true
  })
});

API

hash(password, options, callback)

Creates a new 'unique' hash from a password.

password

Type: string

The password to hash.

options

Type: object

Configurations for the hash function.

type

Type: number
Default: 0

The type option is flexible and accepts. 0, 1 or 2 for Argon2d, Argon2i and Argon2id respectively.

timeCost

Type: number
Default: 3

The amount of computation realized and therefore the execution time, given in number of iterations.

memoryCost

Type: number
Default: 12

The memory usage, given in kibibytes.

parallelism

Type: number
Default: 1

The number of parallel threads.

hashLength

Type: number
Default: 32

The length of the generated hash.

callback(err, hash)

Type: function

Called after the hash has been computed.

err

Type: object

Possible error thrown.

hash

Type: object

The generated hash.

verify(hash, input, callback)

Determines whether or not the user's input matches the stored password.

hash

Type: string

An hash generated from this package.

input

Type: string

User's input input.

callback(err, valid)

Type: string

Called after the verification process has been computed.

err

Type: object

Possible error thrown.

valid

Type: boolean

True if the hash computed for the input matches.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

🛡 argon2 plugin for credential-plus

License:MIT License


Languages

Language:JavaScript 100.0%