1.0.1 • Published 7 years ago

password-strength-calculator v1.0.1

Weekly downloads
29
License
ISC
Repository
github
Last release
7 years ago

Hella strong password strength calculator

The strongest password strength calculator EVER!

npm version CircleCI CircleCI CircleCI

Features

  • Add custom bad words
  • No dependencies
  • ES6 compatable
  • Fully tested
  • Min and max password lengths
  • Meets SISR Standards

Example usage

JS example

import PasswordStrength from "password-strength-calculator";

const passTest = new PasswordStrength({ minLength: 10 });
const strength = passTest("mypassword");

if (strength < 60) console.log("password is weak");
else console.log("password is good");

React example

import React, {Component} from 'react'
import PasswordStrength from 'password-strength-calculator'

const passTest = new PasswordStrength({...})
const MIN_PASS_STREGTH = 80

export default Form extends Component {
  state = {
    passwordValid: false
  }

  passwordValidation = (event) => {
    const value = event.target.value
    this.setState({passwordValid: passTest(value) >= MIN_PASS_STRENGTH})
  }

  render(){
    <form>
      <input
        className={this.state.passwordValid ? 'form-field-valid' : 'form-field-invalid'}
        onChange={this.passwordValidation}
      />
    </form>
  }
}

Options

OPTIONTYPEDEFAULTDESCRIPTION
minLengthnumber8The min length for a password
maxLengthnumber24The max length for a password
badWordsarray'qwerty', 'abc123', 123abc','welcome', 'password', 'jesus', 'abc', 'test'Add an array of bad words for passwords

Contribution

Feel free to open a PR or endorse me on linkedin! Endorsements would be much appreciated!

Development

  • Pull down the latest from github.
  • Run npm install
  • Modify the /src/index.js file
  • Run tests npm test
1.0.1

7 years ago

1.0.0

7 years ago