PHPackages                             abdullahhafizh/zxcvbn-php - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. abdullahhafizh/zxcvbn-php

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

abdullahhafizh/zxcvbn-php
=========================

Realistic password strength estimation PHP library based on Zxcvbn JS

2.0.0(3y ago)135↓100%MITPHPPHP ^5.0 | ^5.1 | ^5.6 | ^7.2 | ^8.0 | ^8.1

Since Apr 7Pushed 3y agoCompare

[ Source](https://github.com/abdullahhafizh/zxcvbn-php)[ Packagist](https://packagist.org/packages/abdullahhafizh/zxcvbn-php)[ Docs](https://github.com/abdullahhafizh/zxcvbn-php)[ Fund](https://issuehunt.io/r/abdullahhafizh)[ Fund](https://ko-fi.com/abdullahhafizh)[ RSS](/packages/abdullahhafizh-zxcvbn-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (22)Used By (0)

Zxcvbn-PHP is a password strength estimator using pattern matching and minimum entropy calculation. Zxcvbn-PHP is based on the [the Javascript zxcvbn project](https://github.com/dropbox/zxcvbn) from [Dropbox and @lowe](https://blogs.dropbox.com/tech/2012/04/zxcvbn-realistic-password-strength-estimation/). "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.

[![Build Status](https://camo.githubusercontent.com/7d84aa999474a0898c59f3cfaa94a9f743db6400de1b78614439fab0e79e96b6/68747470733a2f2f7472617669732d63692e6f72672f626a6561766f6e732f7a786376626e2d7068702e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/bjeavons/zxcvbn-php)[![Coverage Status](https://camo.githubusercontent.com/b238f298477e3f027d655041d2c117bd02bfdf4b7cf3e8d984578fd81572b2b8/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f626a6561766f6e732f7a786376626e2d7068702f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/bjeavons/zxcvbn-php?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/09646389a29816816e7ea8767013e2a9d19a66d4187aa29e106fcb5626606ff5/68747470733a2f2f706f7365722e707567782e6f72672f626a6561766f6e732f7a786376626e2d7068702f762f737461626c65)](https://packagist.org/packages/bjeavons/zxcvbn-php)[![License](https://camo.githubusercontent.com/273153277d7124a95e2fafa7c22be86e276d790bb898fb4b5b1cb8d2995d1f7d/68747470733a2f2f706f7365722e707567782e6f72672f626a6561766f6e732f7a786376626e2d7068702f6c6963656e7365)](https://packagist.org/packages/bjeavons/zxcvbn-php)

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

[](#installation)

The library can be installed with [Composer](http://getcomposer.org) by adding it as a dependency to your composer.json file.

Via the command line run: `composer require bjeavons/zxcvbn-php`

Or in your composer.json add

```
{
    "require": {
        "bjeavons/zxcvbn-php": "^1.0"
    }
}
```

Then run `composer update` on the command line and include the autoloader in your PHP scripts so that the ZxcvbnPhp class is available.

```
require_once 'vendor/autoload.php';
```

Usage
-----

[](#usage)

```
use ZxcvbnPhp\Zxcvbn;

$userData = [
  'Marco',
  'marco@example.com'
];

$zxcvbn = new Zxcvbn();
$weak = $zxcvbn->passwordStrength('password', $userData);
echo $weak['score']; // will print 0

$strong = $zxcvbn->passwordStrength('correct horse battery staple');
echo $strong['score']; // will print 4

echo $weak['feedback']['warning']; // will print user-facing feedback on the password, set only when score
