Skip to content

Easy and secure password hashing with salt in Node.js.

License

Notifications You must be signed in to change notification settings

robojones/pw-hash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Easy and secure password hashing with salt in Node.js.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published