2017 © Pedro Peláez
 

library riddler

Password generator service

image

degraciamathieu/riddler

Password generator service

  • Friday, June 22, 2018
  • by DeGraciaMathieu
  • Repository
  • 1 Watchers
  • 8 Stars
  • 240 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 8 Versions
  • 22 % Grown

The README.md

, (*1)

Codacy Badge Scrutinizer Code Quality Build Status Code Coverage Latest Version on Packagist , (*2)

DeGraciaMathieu/Riddler

Password generator service, (*3)

Installation

Run in console below command to download package to your project:, (*4)

composer require degraciamathieu/riddler

Password generation usage

A password is a set of one or more criteria composed of a dictionary and an occurrence., (*5)

The available dictionaries are : * AccentedLetter * AccentedUppercaseLetter * Digit * Letter * SpecialCharacter * UppercaseLetter, (*6)

Available occurrences : * Strict * Between * None, (*7)

require 'vendor\autoload.php';

use DeGraciaMathieu\Riddler\Password;
use DeGraciaMathieu\Riddler\Dictionaries;
use DeGraciaMathieu\Riddler\Occurrences;

$password = new Password();
$password->addCriteria(new Dictionaries\Digit(), new Occurrences\Strict(5));
$password->addCriteria(new Dictionaries\Letter(), new Occurrences\Between(3, 6));
$password->generate();

To build passwords faster, it is possible to use a set of prescinded criteria using the formats., (*8)

Available formats : * LongDigit * MixedComplex * MixedStrong * SmallAlphanumeric * StrongAlphanumeric, (*9)

require 'vendor\autoload.php';

use DeGraciaMathieu\Riddler\Password;
use DeGraciaMathieu\Riddler\Formats;

$password = new Password();
$password->addFormat(new Formats\StrongAlphanumeric());
$password->generate();

It is possible to create its own class format implementing the interface DeGraciaMathieu\Riddler\Contracts\Format, (*10)

Check password score

It's also possible to check if a passwords matches the required list of criteria with the Score method., (*11)

$password = new Password;
$password->addCriteria(new Digit(), new Strict(3));
$password->addCriteria(new Letter(), new Between(3, 5));
$password->score('123abcd'); // 100

$password = new Password;
$password->addCriteria(new Digit(), new Strict(3));
$password->addCriteria(new Letter(), new Between(3, 5));
$password->score('123a'); // 50

The value of the score method being the percentage of validated criteria., (*12)

Check password passed

$password = new Password;
$password->addCriteria(new Digit(), new Strict(3));
$password->addCriteria(new Letter(), new Between(3, 5));
$password->passed('123a');

// [
//     ['name' => 'digit_strict_3', 'passed' => true],
//     ['name' => 'letter_between_3_5', 'passed' => false],
// ]
$password = new Password;
$password->addNamedCriteria('MyName', new Digit(), new Strict(3));
$password->passed('123');

// [
//     ['name' => 'MyName', 'passed' => true],
// ]

Examples

Classics

$password = new Password;
$password->addCriteria(new Digit(), new Strict(10));
$password->generate(); // "4731412968"

$password = new Password;
$password->addCriteria(new Letter(), new Strict(20));
$password->generate(); // "tugmdzkgohnnkfrxuqns"

$password = new Password;
$password->addCriteria(new UppercaseLetter(), new Strict(20));
$password->generate(); // "JDXIRCEBWDPZLCWIJNYZ"

$password = new Password;
$password->addCriteria(new UppercaseLetter(), new Between(5, 7));
$password->addCriteria(new Letter(), new Between(5, 7));
$password->generate(); // "xIXPstuqTZmb"

$password = new Password;
$password->addCriteria(new SpecialCharacter(), new Strict(15));
$password->generate(); // "#^_=%§][:@_]^%="

$password = new Password;
$password->addCriteria(new AccentedLetter(), new Strict(15));
$password->generate(); // "üãöîâüîüûàóäùéú"

$password = new Password;
$password->addCriteria(new AccentedUppercaseLetter(), new Strict(15));
$password->generate(); // "ÂÚÏÝÒÌÀÂÜÝÛËÍÊÌ"

$password = new Password;
$password->addCriteria(new Digit(), new Strict(5));
$password->addCriteria(new Letter(), new Strict(5));
$password->addCriteria(new SpecialCharacter(), new Between(5, 10));
$password->generate(); // "!186u;n&~§3r7hb|~?"

$password = new Password;
$password->addCriteria(new Digit(), new Between(5, 7));
$password->addCriteria(new Letter(), new Between(5, 7));
$password->addCriteria(new UppercaseLetter(), new Between(5, 7));
$password->addCriteria(new AccentedLetter(), new Between(5, 7));
$password->addCriteria(new SpecialCharacter(), new Between(5, 7));
$password->generate(); // "uELòp§iO°L§7b~â]3ûë7èm96A"

Formats

$password = new Password();
$password->addFormat(new Formats\LongDigit());
$password->generate(); // "075197457894437657185665450123"

$password = new Password();
$password->addFormat(new Formats\SmallAlphanumeric());
$password->generate(); // "mA5M6ap167gRTeE"

$password = new Password();
$password->addFormat(new Formats\StrongAlphanumeric());
$password->generate(); // "492OHwdJEdDT5Lb89zhY9c26j4XhmX"

$password = new Password();
$password->addFormat(new Formats\MixedStrong());
$password->generate(); // "41súdSXWHV65k2G0lr0õèñzåY"

$password = new Password();
$password->addFormat(new Formats\MixedComplex());
$password->generate(); // "Äûc[%ÀÁkWï_1V8k3uw*3§ÔEaAÍ+5§ôåûWYI6äÕ7"

The Versions

22/06 2018

dev-master

9999999-dev https://github.com/degraciamathieu/riddler

Password generator service

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by De Gracia Mathieu

laravel generator password

22/06 2018

v1.3.1

1.3.1.0 https://github.com/degraciamathieu/riddler

Password generator service

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by De Gracia Mathieu

laravel generator password

28/03 2018

v1.3.0

1.3.0.0 https://github.com/degraciamathieu/riddler

Password generator service

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by De Gracia Mathieu

laravel generator password

08/03 2018

v1.2.0

1.2.0.0 https://github.com/degraciamathieu/riddler

Password generator service

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by De Gracia Mathieu

laravel generator password

04/03 2018

v1.1.0

1.1.0.0 https://github.com/degraciamathieu/riddler

Password generator service

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by De Gracia Mathieu

laravel generator password

07/02 2018

v1.0.2

1.0.2.0 https://github.com/degraciamathieu/riddler

Password generator service

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by De Gracia Mathieu

laravel generator password

31/01 2018

v1.0.1

1.0.1.0 https://github.com/degraciamathieu/riddler

Password generator service

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by De Gracia Mathieu

laravel generator password

14/01 2018

v1.0.0

1.0.0.0 https://github.com/degraciamathieu/riddler

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by De Gracia Mathieu

laravel generator password