0.1.1 • Published 8 years ago

pw-hash v0.1.1

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

pw-hash

Easy and secure password hashing with salt.

Build Status Test Coverage License: MIT

bitHound Code bitHound Overall Score bitHound Dependencies

Highlights

  • 100% tested.
  • No dependencies.
  • Uses a strong hash algorithm by default (sha256).
  • Appends a random string (salt) to each password before hashing it (for extra security).
  • JSDoc documentation for completion in editors like VS Code.

Installation

npm i pw-hash

Usage

const hash = require('pw-hash')

// hash a password:
const hashString = hash.create('example password')


// verify if a password matches
hash.verify('wrong password', hashString) // false
hash.verify('example password', hashString) // true

API

hash.create(password)

  • password <string> - A string containing the password.

Returns a string that can be stored in the database. It can be used with the verify method to check if a password matches.

hash.verify(password, hashString)

  • password <string> - A string containing the password.
  • hashString <string> - A string that was created with the .create() method.

This method verifies if the password is the same password that you passed to the .create() method. It Returns true if the password matches or false if it doesn't.