0.2.1 • Published 3 years ago
wops v0.2.1
Wops
A simple package to work with password in JS / TS
Installation
npm
npm install wops yarn
yarn add wopsUsage
import {
generatePassword,
validatePassword,
hashPassword,
checkPasswordStrength
} from 'wops'
const password = generatePassword(10, true)
const { hash, salt } = hashPassword("YOUR PASSWORD")
const isValid = validatePassword("YOUR PASSWORD", salt, hash)
const passwordStrength = checkPasswordStrength("YOUR PASSWORD")Functions
Typedefs
generatePassword(length, useUpper, useNumber, useSpecial) ⇒ string
Generates a password according to the specified parameters
Kind: global function Returns: string - password
| Param | Type |
|---|---|
| length | string |
| useUpper | boolean |
| useNumber | boolean |
| useSpecial | boolean |
hashPassword(pswd) ⇒ HashAndSalt
Given a Password, hash it with a salt, then return the hash and the salt
Kind: global function Returns: HashAndSalt - object containing the hash and the salt used
| Param | Type |
|---|---|
| pswd | string |
validatePassword(inpPswd, salt, storedHash) ⇒ boolean
Does the given password match with the hash?
Kind: global function Returns: boolean - does hash(inpPswd + salt) === storedHash?
| Param | Type |
|---|---|
| inpPswd | string |
| salt | string |
| storedHash | string |
checkPasswordStrength(pswd)
The checkPasswordStrength function checks how strong the entered password is
Kind: global function
| Param | Type |
|---|---|
| pswd | string |
HashAndSalt : Object
Kind: global typedef Properties
| Name | Type | Description |
|---|---|---|
| hash | string | The hash we got |
| salt | string | The salt used for hashing |