pw-hash
Easy and secure password hashing with salt.
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 = // hash a password:const hashString = hash // verify if a password matcheshash // falsehash // 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.