mkopinsky / zxcvbn-php
Realistic password strength estimation PHP library based on Zxcvbn JS
Installs: 473 196
Dependents: 1
Suggesters: 1
Security: 0
Stars: 23
Watchers: 5
Forks: 79
Open Issues: 1
Requires
- php: ^5.6 || ^7.0
- symfony/polyfill-mbstring: >=1.3.1
Requires (Dev)
This package is auto-updated.
Last update: 2021-02-15 03:27:40 UTC
README
Zxcvbn-PHP is a password strength estimator using pattern matching and minimum entropy calculation. Zxcvbn-PHP is based on the the Javascript zxcvbn project from Dropbox and @lowe. "zxcvbn" is bad password, just like "qwerty" and "123456".
zxcvbn attempts to give sound password advice through pattern matching and conservative entropy calculations. It finds 10k common passwords, common American names and surnames, common English words, and common patterns like dates, repeats (aaa), sequences (abcd), and QWERTY patterns.
Installation
The library can be installed with Composer by adding it as a dependency to your composer.json file.
{ "require": { "mkopinsky/zxcvbn-php": "^4.4.2" } }
After running php composer.phar update
on the command line, include the
autoloader in your PHP scripts so that the ZxcvbnPhp class is available.
require_once 'vendor/autoload.php';
Usage
use ZxcvbnPhp\Zxcvbn; $userData = [ 'Marco', 'marco@example.com' ]; $zxcvbn = new Zxcvbn(); $strength = $zxcvbn->passwordStrength('password', $userData); echo $strength['score']; // will print 0 $strength = $zxcvbn->passwordStrength('correct horse battery staple'); echo $strength['score']; // will print 4
Acknowledgements
Thanks to:
- @lowe for the original Javascript Zxcvbn
- @Dreyer's port for reference for initial implementation
- bjeavon's implementation for building out zxcvbn-php as a solid initial port of the Dropbox library with composer support and unit tests