Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bcrypt-password-hash

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bcrypt-password-hash

hash passwords with bcrypt

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by50%
Maintainers
1
Weekly downloads
 
Created
Source

bcrypt-password-hash

hash password with bcrypt

NPM version

Generation and validation of passwords using bcrypt hashes. Uses same api as pbkdf2-password-hash.

Requires node >= v8.0.0

TOC

Example

Generate new password hash

const passwordHash = require('bcrypt-password-hash')

// generates random salt
passwordHash.hash('password')
  .then((hash) => {
    //> hash === 'bcrypt$2b$10$Y6MKD5ZI5gtkvBdYyqwr1.CrHA66ppM/9YNDvacUuqWZSVduKQcIq'
  })

Generate password hash with different options

passwordHash.hash('password', {saltRounds: 14})
.then((hash) => {
  //> hash === 'bcrypt$2b$14$9zjobUQJ9LVswQrQJ7leKe6NnJKMc3ZouykkhZZ6uFa9ARMZVSUgy'
})

Validate password hash

const hash = 'bcrypt$2b$14$9zjobUQJ9LVswQrQJ7leKe6NnJKMc3ZouykkhZZ6uFa9ARMZVSUgy'
passwordHash.compare('password', hash)
.then((isValid) => {
  //> isValid === true
})

API

hash(password, [salt], [opts])

Generate a new password hash for password using bcrypt.

Parameters

parametertypedescription
passwordString
[salt]Stringoptional: salt
[opts.saltRound=10]Numberoptional: number of iterations

Returns Promise, hashed password in bcrypt$<version>$<saltRound>$<salt><hash> notation.

compare(password, passwordHash)

validate password against passwordHash

Parameters

parametertypedescription
passwordStringplain-text password
passwordHashStringhashed password

Returns Promise, true if hash matches password

Installation

Requires nodejs >= v8.0.0

$ npm install --save bcrypt-password-hash

Tests

$ npm test

LICENSE

UNLICENSE https://unlicense.org

Keywords

FAQs

Package last updated on 01 Jul 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc