PHPackages                             niirrty/niirrty.security.password - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. niirrty/niirrty.security.password

ActiveLibrary[Security](/categories/security)

niirrty/niirrty.security.password
=================================

A little password-security library

0.1.0(8y ago)04[2 issues](https://github.com/Niirrty/Niirrty.Security.Password/issues)MITPHPPHP &gt;=7.1

Since Jan 9Pushed 8y agoCompare

[ Source](https://github.com/Niirrty/Niirrty.Security.Password)[ Packagist](https://packagist.org/packages/niirrty/niirrty.security.password)[ RSS](/packages/niirrty-niirrtysecuritypassword/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Niirrty.Security.Password
=========================

[](#niirrtysecuritypassword)

A little password-security library.

It defines only a single class `Niirrty\Security\Password\PasswordSecurityCheck` that can be used to check the quality of a password.

Installation
------------

[](#installation)

Its a composer package, so you can install it by composer

```
composer require niirrty/niirrty.security.password ~0.1
```

or inside the composer.json

```
{
   "require": {
      "php": ">=7.1",
      "composer require niirrty/niirrty.security.password": "~0.1"
   }
}
```

How it works?
-------------

[](#how-it-works)

It generates 4 different password quality indicators:

1. **Password Length**: Max quality can be reached by using 11 or more characters
2. **Character diversity**: The quality in relation to how many different chars are used
3. **Character type diversity**: The quality in relation to how many different char types are used (letters-lower, letters-upper, numbers, other)
4. **Known by Top lists**: 1 if known by Top 10 password lists, 2 if known by Top 25 password lists and 5 if known by Top 50 password lists, otherwise 10

The check, if a password is inside a password list Top 10/25/50 uses a SQLite DB in Background. The DB defines all unique Top10, Top25 and Top50 passwords, extracted from [SecLists](https://github.com/danielmiessler/SecLists)password files, excluding spanish and not \*.txt files.

Each uses a value between 0 (no security) and 10 (max security)

The lowest value of the 4 indicators will be returned by -&gt;getQuality()

The password self is not stored inside a class instance.

Usage
-----

[](#usage)

This is a simple usage example:

```
# include __DIR__ . '/vendor/autoload.php';

use \Niirrty\Security\Password\PasswordSecurityCheck;

$passwords = [
   '',
   '0',
   '1',
   '22',
   'aaa',
   'aaaa',
   'AAAAA',
   '123456',
   '_______',
   'gEhe1m',
   '$4QT5/_8',
   '123456789'
];

foreach ( $passwords as $password )
{
   echo $password, ': ', ( new PasswordSecurityCheck( $password ) )->getQuality(), "\n";
}
```

will output:

```
: 0
