Skip to content

15ludyna/wops

Repository files navigation

Wops

A simple package to work with password in JS / TS

Installation

npm

npm install wops 

yarn

yarn add wops

Usage

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

generatePassword(length, useUpper, useNumber, useSpecial)string

Generates a password according to the specified parameters

hashPassword(pswd)HashAndSalt

Given a Password, hash it with a salt, then return the hash and the salt

validatePassword(inpPswd, salt, storedHash)boolean

Given an input password a salt and an hash Does the given password match with the hash?

checkPasswordStrength(pswd)

The checkPasswordStrength function checks how strong the entered password is

Typedefs

HashAndSalt : Object

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

About

A simple package to work with password in JS / TS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published