Socket
Socket
Sign inDemoInstall

@sensu/couch-pwd

Package Overview
Dependencies
0
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @sensu/couch-pwd

CouchDB salt and password generation with PBKDF2


Version published
Weekly downloads
65
increased by8.33%
Maintainers
2
Install size
5.45 kB
Created
Weekly downloads
 

Readme

Source

@sensu/couch-pwd Build Status

An up-to-date version of couch-pwd that is actually published.

Hash and compare passwords with the crypto's pbkdf2. Heavily inspired by node-pwd.

Uses the following values as defaults

  • iterations = 10
  • keylen = 20
  • size = 16
  • encoding = 'hex'

The resulting salt and password Strings are the same you'd get when you save a user to CouchDB and let CouchDB do all the hashing for you.

Module has two goals

  • verify user passwords without making requests to /_session API
  • use the same hashing algorithm for other databases

Installation

npm install couch-pwd

Example

On signup generate a salt / password hash, and save it somewhere:

var pwd = require('couch-pwd');
pwd.hash('my password', function(err, salt, hash){
  user.salt = salt;
  user.hash = hash;
})

To authenticate load and compare:

var pwd = require('couch-pwd');
pwd.hash('submitted password', user.salt, function(err, hash){
  if (user.hash == hash) {
    // yay
  }
})

License

MIT

Keywords

FAQs

Last updated on 19 Sep 2017

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc