Skip to main content
Deno 2 is finally here πŸŽ‰οΈ
Learn more

CI

pwchecker

pwchecker is a simple password checker. It provides a password policy check, for instance length of password, minimum number of digits etc. The entropy of the password can be determined and classifies the password strength from β€œvery weak” (score: 1) to β€œvery strong” (score 5).

Entropy

The pwchecker module exports the function password_strength which will return a result dictionary with the following keys:

  • entropy: # bits
  • score: [1, 2, 3, 4, 5] where 1 means β€œvery weak” and 5 means β€œvery strong”
  • text: [ β€œvery weak”, β€œweak”, β€œreasonable”, β€œstrong”, β€œvery strong” ] where a password is classified as β€œvery strong” if its entropy is at least 128 bits
  • cracktime: how long it will take to get the password via bruteforce

Usage:

import { password_strength } from "./mod.ts";

var password: string = "jelly22Fi$h";

var output = {
    entropy: password_strength(password).entropy,
    cracktime: password_strength(password).cracktime,
    score: password_strength(password).score,
    text: password_strength(password).text
};
console.table(output);

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   (idx)   β”‚      Values       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  entropy  β”‚ 72.10047736845401 β”‚
β”‚ cracktime β”‚    "centuries"    β”‚
β”‚   score   β”‚         4         β”‚
β”‚   text    β”‚     "strong"      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Policy Check

The module contains the class PasswordPolicy that defined some check properties.

Usage:

const pwpolicy = new PasswordPolicy();

var policyResult = pwpolicy.password_policy_compliance("123456");

The policyResult contains for example:

{
    hasMinLen: false,
    hasMinUppercase: false,
    hasMinLowercase: false,
    hasMinSpecialChars: false,
    hasMinDigits: true
}

The password policies in PasswordPolicy can be overwritten to fit the security requirements for a password. The default values are:

pwpolicy.minLen = 10;
pwpolicy.minUppercase = 1;
pwpolicy.minLowercase = 1;
pwpolicy.minSpecialChars = 1;
pwpolicy.minDigits = 1;