A simple package to hash passwords and verify if the password and hash match
yarn add hashed-password
import { validatePassword, hashPassword, randomPassword } from "hashed-password"
const {hash, salt} = hashPassword("YOUR PASSWORD");
const isValid = validatePassword("YOUR PASSWORD", salt, hash);
const securePass = randomPassword(10,{numbers: false, symbols: false})
Demo : Demo Url
React Sample: Code Sandbox
- validatePassword(inputPassword, salt, storedHash) ⇒
boolean
Given an input password a salt and an hash Does the given password mathc with the hash
- hashPassword(password) ⇒
HashAndSalt
Given a Password and hash it with a salt, then return the hash and the salt
- randomPassword(length, options) ⇒
string
Returns a random password based on given params
- HashAndSalt :
Object
Given an input password a salt and an hash Does the given password mathc with the hash
Kind: global function
Returns: boolean
- does hash(input Password + salt ) === storedHash?
Param | Type |
---|---|
inputPassword | string |
salt | string |
storedHash | string |
hashPassword(password) ⇒ HashAndSalt
Given a Password and hash it with a salt, then return the hash and the salt
Kind: global function
Returns: HashAndSalt
- object containing the hash and the salt usedP
Param | Type |
---|---|
password | string |
Returns a random password based on given params
Kind: global function
Param | Type |
---|---|
length | number |
options | passwordOptions |
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
hash | string |
The hash we got |
salt | string |
The salt used for hashing |