1.0.4 • Published 3 years ago

password-strength-score v1.0.4

Weekly downloads
116
License
MIT
Repository
github
Last release
3 years ago

password-strength-score

npm npm Coverage Status Build Status License

Smallish password strength utility.

Installation

npm i password-strength-score --save

Alternatively you may use yarn:

yarn add password-strength-score

Link to npm: https://www.npmjs.com/package/password-strength-score

Usage

Basic

import { passwordStrength } from 'password-strength-score';

passwordStrength('pass'); // returns 1 because password has only lowercase chars
passwordStrength('pass1'); // returns 2 because password has lowercase chars and a number

Strength meter component utility

import { passwordStrength, PasswordStrength } from 'password-strength-score';
import chroma from 'chroma-js';

const getPasswordScoreGradientColor = (password) => {
  const score = passwordStrength(password);
  chroma
    .scale(['#FF4047','#00FF6E'])
    .mode('rgb')
    .colors(PasswordStrength.MaxScore); // generate colors array between #FF4047 - #00FF6E
  
  return colors[score]; // Returns one color between #FF4047 - #00FF6E
};

Score calculation (default settings)

FlagTestPoints
isLongpassword.length > 61
isVeryLongpassword.length > 121
hasUppercase/a-z/1
hasLowercase/A-Z/1
hasNumbers/\d/1
hasNonalphas/\W/1

Options

OptionDescriptionDefault
isLongLength for password to be consider as long6
isVeryLongLength for password to be consider as very long12
withoutUppercaseTurn off score point for uppercase char occurrencefalse
withoutLowercaseTurn off score point for lowercase char occurrencefalse
withoutNumbersTurn off score point for numbers occurrencefalse
withoutNonalphanumericsTurn off score point for alphanumerics char occurrencefalse

Reliability

This package is fully tested with total coverage set to Coverage Status. If you found any issue please report it here.

License

Made with :sparkling_heart: by Bartlomiej Zuber (bartlomiej.zuber@outlook.com) while traveling around the world, and licensed under the MIT License