#password #strength #entropy

bin+lib chbs_password_checker

Password Strength Checker

1 unstable release

0.1.0 May 17, 2021

#599 in Authentication

Download history 25/week @ 2024-02-19 18/week @ 2024-02-26 6/week @ 2024-03-04 47/week @ 2024-03-11

96 downloads per month

MIT license

17KB
298 lines

CHBS Password Strength Checker

A simple password strength checker using raw entropy values written in Rust.

Inspired by: https://github.com/wagslane/go-password-passwordvalidator and this XKCD

Benefits

  • While uppercase, numbers, special characters, etc... all count towards the final score, none are required
  • Does not contact any external API's
  • Includes command line tool in addition to a library so it can be used in bash scripts

⚙️ Installation

cargo install chbs

Use in code::

use chbslib::get_entropy;

let test_1: String = String::from("boring");
let score: i16 = get_entropy(&test1);
println!("Score: {}", score);

>>> 1

What is a good minimum value?

That's a judgement call. I would suggest something in the range of 5 to 7 or so.

Caveats

Attackers commonly use passwords they have scraped from leaked data. Entropy checks will NOT protect your users from using leaked passwords.

How It Works

The password is stripped of repeating characters, palindrome portions, and common password sequences like qwerty or asdfghjkl as well as the set of the 10 most commonly used passwords (according to wikipedia). The remaining length accounts for the initial score. Additional points are awarded for mixing case, adding numbers, and adding special characters.

After that we do some maths which calculates the approximate total guesses and reduces this to a integer score.

Dependencies

~1MB
~13K SLoC