sonalan / hashed-password

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

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


Languages

Language:HTML 43.0%Language:CSS 30.4%Language:JavaScript 16.1%Language:TypeScript 10.4%