0.2.1 • Published 1 year ago

wops v0.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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

Typedefs

generatePassword(length, useUpper, useNumber, useSpecial) ⇒ string

Generates a password according to the specified parameters

Kind: global function Returns: string - password

ParamType
lengthstring
useUpperboolean
useNumberboolean
useSpecialboolean

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

ParamType
pswdstring

validatePassword(inpPswd, salt, storedHash) ⇒ boolean

Does the given password match with the hash?

Kind: global function Returns: boolean - does hash(inpPswd + salt) === storedHash?

ParamType
inpPswdstring
saltstring
storedHashstring

checkPasswordStrength(pswd)

The checkPasswordStrength function checks how strong the entered password is

Kind: global function

ParamType
pswdstring

HashAndSalt : Object

Kind: global typedef Properties

NameTypeDescription
hashstringThe hash we got
saltstringThe salt used for hashing
0.2.1

1 year ago

0.2.0

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago