Skip to content

A simple package to hash passwords and verify if the password and hash match

Notifications You must be signed in to change notification settings

sonalan/hashed-password

Repository files navigation

Hashed Password

A simple package to hash passwords and verify if the password and hash match

Installation

yarn add hashed-password

Ussage

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 : Demo Url

React Sample: Code Sandbox

Functions

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

Typedefs

HashAndSalt : Object

validatePassword(inputPassword, salt, storedHash) ⇒ boolean

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

randomPassword(length, options) ⇒ string

Returns a random password based on given params

Kind: global function

Param Type
length number
options passwordOptions

HashAndSalt : Object

Kind: global typedef
Properties

Name Type Description
hash string The hash we got
salt string The salt used for hashing