PHP code example of degraciamathieu / riddler

1. Go to this page and download the library: Download degraciamathieu/riddler library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

degraciamathieu / riddler example snippets



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();


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

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

$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

$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],
// ]

$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"

$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"