emavola / credential-plus

🛡 Easy password hashing and verification in Node.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

credential-plus

Travis CI Codecov npm npm version npm dependencies npm dev dependencies

🛡 Easy password hashing and verification in Node. Protects against brute force, rainbow tables, and timing attacks.

Install

$ npm install --save credential-plus

Usage

const credential = require('credential-plus');
// Coming soon.

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.

func

Type: string
Default: 'pbkdf2'

The name of the hash function to use. Can be one of: 'pbkdf2', 'bcrypt', 'scrypt','argon2'

Options available are different for each hash function. See here the list.

callback(err, hash)

Type: function

Called after the hash has been computed.

err

Type: object

Possible error thrown.

hash

Type: object

Stringified hash object that holds the generated hash string, the name of the function used and the parameters passed to the hash funciton needed for the verification process.

verify(hash, input, callback)

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

hash

Type: string

Stringified hash object 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.

Options

pbkdf2

iterations

Type: number
Default: 10000

Description

keylen

Type: number
Default: 128

Description

digest

Type: string
Default: 'sha512'

Description

bcrypt

rounds

Type: number
Default: 10

Description

scrypt

maxtime

Type: number
Default: 0.15

Description

maxmem

Type: number
Default: 0

Description

maxmemfrac

Type: number
Default: 0.5

Description

argon2

type

Type: number
Default: 0

Description

timeCost

Type: number
Default: 3

Description

memoryCost

Type: number
Default: 12

Description

parallelism

Type: number
Default: 1

Description

hashLength

Type: number
Default: 32

Description

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

🛡 Easy password hashing and verification in Node.

License:MIT License


Languages

Language:JavaScript 100.0%