2017 © Pedro Peláez
 

library l5-zxcvbn

Implementation of the zxcvbn project by @dropbox for Laravel 5. Uses zxcvbn-php by @bjeavons.

image

olssonm/l5-zxcvbn

Implementation of the zxcvbn project by @dropbox for Laravel 5. Uses zxcvbn-php by @bjeavons.

  • Saturday, June 9, 2018
  • by olssonm
  • Repository
  • 1 Watchers
  • 13 Stars
  • 7,417 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 4 Forks
  • 0 Open issues
  • 8 Versions
  • 22 % Grown

The README.md

Zxcvbn for Laravel

Latest Version on Packagist ![Total downloads][ico-downloads] Software License Build Status, (*1)

zxcvbn, (*2)

A simple implementation of zxcvbn for Laravel. This package allows you to access "zxcvbn-related" data on a passphrase in the application and also to use zxcvbn as a standard validator., (*3)

Uses Zxcvbn-PHP by @bjeavons, which in turn is inspired by zxcvbn by @dropbox., (*4)

Install

Via Composer, (*5)

$ composer require olssonm/l5-zxcvbn

If you wish to have the ability to use Zxcvbn via dependency injection, or just have a quick way to access the class – add an alias to the facades:, (*6)

'aliases' => [
    'Zxcvbn' => Olssonm\Zxcvbn\Facades\Zxcvbn::class
]

Usage

If you've added Olssonm\Zxcvbn as an alias, your can access Zxcvbn easily from anywhere in your application:, (*7)

"In app"

``` php use Zxcvbn;, (*8)

class MyClass extends MyOtherClass { public function myFunction() { $zxcvbn = Zxcvbn::passwordStrength('password'); dd($zxcvbn);, (*9)

    // array:9 [
    //     "password" => "password"
    //     "guesses" => 3.0
    //     "guesses_log10" => 0.47712125471966
    //     "sequence" => [],
    //     "crack_times_seconds" => array:4 [
    //         "online_throttling_100_per_hour" => 108.0
    //         "online_no_throttling_10_per_second" => 0.3
    //         "offline_slow_hashing_1e4_per_second" => 0.0003
    //         "offline_fast_hashing_1e10_per_second" => 3.0E-10
    //     ]
    //     "crack_times_display" => array:4 [
    //         "online_throttling_100_per_hour" => "2 minutes"
    //         "online_no_throttling_10_per_second" => "less than a second"
    //         "offline_slow_hashing_1e4_per_second" => "less than a second"
    //         "offline_fast_hashing_1e10_per_second" => "less than a second"
    //     ]
    //     "score" => 0
    //     "feedback" => array:2 [
    //         "warning" => "This is a top-10 common password"
    //         "suggestions" => array:1 [
    //         0 => "Add another word or two. Uncommon words are better."
    //         ]
    //     ]
    //     "calc_time" => 0.020488977432251
    // ]
}

}, (*10)


Play around with different passwords and phrases, the results may surprise you. Check out [Zxcvbn-PHP](https://github.com/bjeavons/zxcvbn-php) for more uses and examples. ### As a validator The package makes two types of validations available for your application. `zxcvbn` and `zxcvbn_dictionary`. ### zxcvbn With this rule you set the lowest score that the phrase need to score wuth Zxcvbn to pass. **Syntax** ``` php 'input' => 'zxcvbn:min_value'

Examples, (*11)

``` php $request->validate([ 'password' => 'required|zxcvbn:3' ]);, (*12)


You may also initialize the rule as an object: ``` php use Olssonm\Zxcvbn\Rules\Zxcvbn; function rules() { return [ 'password' => ['required', new Zxcvbn($minScore = 3)] ]; }

In this example the password should at least have a "score" of three (3) to pass the validation. Of course, you should probably use the zxcvbn-library on the front-end too to allow the user to know this before posting the form., (*13)

zxcvbn_dictionary

This is a bit more interesting. zxcvbn_dictionary allows you to input both the users username and/or email together with their password (you need suply one piece of user input). The validator checks that the password doesn't exist in the username, or that they are too similar., (*14)

Syntax, (*15)

``` php 'input' => 'zxcvbn_dictionary:input1,input2', (*16)


**Examples** ``` php $request->validate([ 'password' => sprintf('required|zxcvbn_dictionary:%s,%s', $request->username, $request->email) ]);

``` php use Olssonm\Zxcvbn\Rules\ZxcvbnDictionary;, (*17)

function rules() { return [ 'password' => ['required', new ZxcvbnDictionary($this->username)] ]; }, (*18)


## Testing ```bash $ composer test

or, (*19)

$ phpunit

License

The MIT License (MIT). Please see the License File for more information., (*20)

© 2022 Marcus Olsson., (*21)

The Versions

09/06 2018

dev-master

9999999-dev https://github.com/olssonm/l5-zxcvbn

Implementation of the zxcvbn project by @dropbox for Laravel 5. Uses zxcvbn-php by @bjeavons.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel validation security passwords zxcvbn olssonm staple horse battery

09/06 2018

dev-dev

dev-dev https://github.com/olssonm/l5-zxcvbn

Implementation of the zxcvbn project by @dropbox for Laravel 5. Uses zxcvbn-php by @bjeavons.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel validation security passwords zxcvbn olssonm staple horse battery

14/02 2018

v3.1

3.1.0.0 https://github.com/olssonm/l5-zxcvbn

Implementation of the zxcvbn project by @dropbox for Laravel 5. Uses zxcvbn-php by @bjeavons.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel validation security passwords zxcvbn olssonm staple horse battery

09/11 2017

v3.0

3.0.0.0 https://github.com/olssonm/l5-zxcvbn

Implementation of the zxcvbn project by @dropbox for Laravel 5. Uses zxcvbn-php by @bjeavons.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel validation security passwords zxcvbn olssonm staple horse battery

29/01 2017

v2.2

2.2.0.0 https://github.com/olssonm/l5-zxcvbn

Implementation of the zxcvbn project by @dropbox for Laravel 5. Uses zxcvbn-php by @bjeavons.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel validation security passwords zxcvbn olssonm staple horse battery

24/01 2017

v2.1

2.1.0.0 https://github.com/olssonm/l5-zxcvbn

Implementation of the zxcvbn project by @dropbox for Laravel 5. Uses zxcvbn-php by @bjeavons.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel validation security passwords zxcvbn olssonm staple horse battery

07/11 2016

v2.0

2.0.0.0 https://github.com/olssonm/l5-zxcvbn

Implementation of the zxcvbn project by @dropbox for Laravel 5. Uses zxcvbn-php by @bjeavons.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel validation security passwords zxcvbn olssonm staple horse battery

16/10 2015

v1.0

1.0.0.0 https://github.com/olssonm/l5-zxcvbn

Implementation of the zxcvbn project by @dropbox for Laravel 5. Uses zxcvbn-php by @bjeavons.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel validation security passwords zxcvbn olssonm staple horse battery