npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

password-scorer

v1.0.7

Published

A simple password strength checker

Downloads

60

Readme

password-scorer

password-scorer is a tool for evaluating the strength of passwords. It provides a score based on various security criteria and offers feedback and descriptions in multiple languages.

Table of Contents

Installation

You can install the package using npm:

npm i password-scorer

Usage

Here is a basic example of how to use password-scorer:

import { passwordScorer } from 'password-scorer';

const result = passwordScorer('YourPassword123!', 'en');
console.log(result);
// Output:
// {
//   score: 100,
//   feedback: [],
//   description: 'perfect'
// }

Function passwordScorer

Parameters

  • password (string): The password you want to evaluate.
  • language (string): The language for feedback and descriptions (optional, default is 'en').

Return

The function returns an object with the following properties:

  • score (number): The password score (from 0 to 100).
  • feedback (string[]): Suggestions on how to improve the password.
  • description (string): A description of the password's strength based on the score.

Supported Languages

| Language | Code | |--------------------|--------| | English | en | | Spanish | es | | German | de | | Simplified Chinese | zh | | Japanese | ja | | Traditional Chinese| zh_TW | | Portuguese | pt | | French | fr |

Example: Using a Different Language (Spanish)

import { passwordScorer } from 'password-scorer';

const result = passwordScorer('TuContraseña123!', 'es');
console.log(result);
// Output:
// {
//   score: 100,
//   feedback: [],
//   description: 'perfecta'
// }

Examples of Passwords with Different Scores

Score: 0 (Very Weak)

const result = passwordScorer('');
console.log(result);
// Output:
// {
//   score: 0,
//   feedback: ["The password is empty."],
//   description: 'very weak'
// }

Score: 20 (Weak)

const result = passwordScorer('1234567');
console.log(result);
// Output:
// {
//   score: 20,
//   feedback: ["Must be more than 8 characters."],
//   description: 'weak'
// }

Score: 40 (Good)

const result = passwordScorer('abcdefgh');
console.log(result);
// Output:
// {
//   score: 40,
//   feedback: ["Must contain at least one number.", "Must contain at least one uppercase letter.", "Must contain at least one symbol (e.g., !, @, #, $, %, ^, &, *)."],
//   description: 'good'
// }

Score: 60 (Very Good)

const result = passwordScorer('abcde123');
console.log(result);
// Output:
// {
//   score: 60,
//   feedback: ["Must contain at least one uppercase letter.", "Must contain at least one symbol (e.g., !, @, #, $, %, ^, &, *)."],
//   description: 'very good'
// }

Score: 80 (Excellent)

const result = passwordScorer('Abcde123');
console.log(result);
// Output:
// {
//   score: 80,
//   feedback: ["Must contain at least one symbol (e.g., !, @, #, $, %, ^, &, *)."],
//   description: 'Excellent'
// }

Score: 100 (Perfect)

const result = passwordScorer('Abcdefg123!');
console.log(result);
// Output:
// {
//   score: 100,
//   feedback: [],
//   description: 'perfect'
// }

Contributions

Contributions are welcome. If you want to add support for a new language or improve the package, please open an issue or a pull.

License

This project is licensed under the MIT License. For more details, see the LICENSE file in the repository.