New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

check-password-strength

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

check-password-strength

A NPM Password strength checker based from Javascript RegExp. Check passphrase if it's "Weak", "Medium" or "Strong"

  • 1.0.13
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
61K
decreased by-5%
Maintainers
1
Weekly downloads
 
Created
Source

Overview

A simple way to check that password strength of a certain passphrase. A password strength checker based from Javascript RegEx.

Build Status npm

DEMO here

Installation

npm i check-password-strength --save

Setup & Basic Usage

const passwordStrength = require('check-password-strength')

console.log(passwordStrength('asdfasdf').value)
// Weak (It will return weak if the value doesn't match the RegEx conditions)

console.log(passwordStrength('Asdfasdf2020').value)
// Medium

console.log(passwordStrength('A@2asdF2020!!*').value)
// Strong

Additional Info

Object

PropertyDesc.
id0 = Weak, 1 = Medium & 2 = Strong
valueWeak, Medium & Strong
containslowercase, uppercase, symbol and/or number
lengthlength of the password
console.log(passwordStrength('@Sdfasd2020!@#$'))
// output 
{ 
    "id": 1, 
    "value": "Strong",
    "contains": [{'message': 'lowercase'},{'message': 'uppercase'},{'message': 'symbol'},{'message': 'number'}],
    "length": 15
}

RegEx

Strong Password RegEx used:

^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#\$%\^&\*])(?=.{8,})

Medium Password RegEx used:

^(((?=.*[a-z])(?=.*[A-Z]))|((?=.*[a-z])(?=.*[0-9]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[A-Z])(?=.*[!@#\$%\^&\*])|((?=.*[a-z])(?=.*[!@#\$%\^&\*])|((?=.*[0-9])(?=.*[!@#\$%\^&\*]))(?=.{6,})"

RegExDesc.
^The password string will start this way
(?=.*[a-z])The string must contain at least 1 lowercase alphabetical character
(?=.*[A-Z])The string must contain at least 1 uppercase alphabetical character
(?=.*[0-9])The string must contain at least 1 numeric character
(?=.[!@#$%^&])The string must contain at least one special character, but we are escaping reserved RegEx characters to avoid conflict
(?=.{8,})The string must be eight characters or longer for strong strength
(?=.{6,})Mininum of 6 characters for medium strength

Other resources

Other resources#### For .NET Project If you're working with .net core project, I've created a simple nuget package with same RegEx strings to validate a password strength.

You can easily install via Nuget Package Manager or .NET CLI (Check.Password.Strength). This package uses Regular Expression new Regex() derives from System.Text.RegularExpressions. You can use this especially if you want to validate the passcode strength on backend services or web apis of your project.

Other NPM RegEx validator

I also made another NPM package (hey-regex) that checks common inputs like numbers (whole number and decimal), alpha numeric, email and url. This package only returns true or false based from the selected function (with RegEx .test() inside).

Reference blog.

Contribute

Feel free to clone or fork this project: https://github.com/deanilvincent/check-password-strength.git

Contributions & pull requests are welcome!

I'll be glad if you give this project a ★ on Github :)

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Keywords

FAQs

Package last updated on 16 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc