Awesome Open Source
Awesome Open Source

GitHub release GitHub issues GitHub last commit Github file size Build Status npm npm Analytics

Pass Score

Get the score of your password as a number.

The number can be between 0 and the length of the provided array containing the conditions against which the password will be tested.

Install

npm i pass-score

or

yarn add pass-score

or

just download this repository and link the files located in dist folder

or include it from unpkg.com

<script src="https://unpkg.com/pass-score"></script>

Usage

With default conditions:

import passScore from 'pass-score';

// Returns a number between 0 and 4
const score = passScore('Your-passW0rd-Str1ng');

With custom conditions

import passScore from 'pass-score';

// Returns a number between 0 and 2
const score = passScore('Your-passW0rd-Str1ng', [
  /[\W_,[email protected]*\(\)]/, // Special characters
  /^.{8}/ // At least 8 characters
]);

Arguments

The function accepts two arguments:

  1. The first is the password string. It is required.
  2. The second is an array of regular expressions. It is optional. The default array is shown below.

Conditions

The predefined array with conditions contains the following:

  1. /\d/ - The password should contain at least on digit
  2. /[A-Z]/, - The password should contain at least one uppercase letter
  3. /[\W_,[email protected]*\(\)]/ - The password should contain at least one special character
  4. /^.{8}/ - The password should be at least 8 characters long

Bonus

The pass-score module provides a native web component. In order to use it you can import it:

import 'pass-score/component';

and then use it as shown in the demo.

The component accepts two attributes: styled: a boolean attribute which injects an opinionated style in the component. patterns: a comma separated list of regular expressions against which the password will be matched.

Support this project

Tweet Donate Become a Patron

LICENSE

MIT


Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Javascript (1,552,087
Webcomponents (2,112
Password Strength (148
Related Projects