emavola / credential-plus-bcrypt

🛡 bcrypt plugin for credential-plus

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

credential-plus-bcrypt

Travis CI Codecov npm npm version npm dependencies npm dev dependencies

🛡 bcrypt 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-bcrypt

Usage

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

// Hash and verify with bcrypt and default configs
credential.hash('We are all unicorns', {func: 'bcrypt'}, (err, hash) => {
  console.log(hash);
  //=> {"hash":"$2a$10$fxxhS75tSP7sP/8UNNJs8uspHSfusSCafU.EhTsn15ENdm/9n3IQe","func":"bcrypt"}
  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.

rounds

Type: number
Default: 10

The cost of processing the data. See here https://www.npmjs.com/package/bcrypt#a-note-on-rounds

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

🛡 bcrypt plugin for credential-plus

License:MIT License


Languages

Language:JavaScript 100.0%