Example 001. Single password

<?php
require_once 'Password.php';
$pwd = Password::getInstance()->generate();
// This is equal to:
// $pwd = Password::getInstance();
// $pwd->generate();
print $pwd;
?>

Output:

2Vccmq3n

Example 002. Single password with dictionary file

<?php
require_once 'Password.php';
$pwd = Password::getInstance()->setDictionary('passwords')->generate();
// This is equal to:
// $pwd = Password::getInstance();
// $pwd->setDictionary('passwords');
// $pwd->generate();
// or
// $pwd = Password::getInstance();
// $pwd->setDictionary('passwords')->generate();
print $pwd;
?>

Output:

B77gEATH

Example 003. Single password with dictionary array

<?php
require_once 'Password.php';
$pwd_array = array('Sample', 'Example', 'Variant', 'Version');
$pwd = Password::getInstance()
     ->setDictionary($pwd_array)
     ->generate();
print $pwd;
?>

Output:

SaMPl98H

Example 004. Single password with custom alphabet

<?php
require_once 'Password.php';
$pwd = Password::getInstance()
     ->setAlphabet(array('a', 'e'), array('b', 'c', 'd'))
     ->generate();
print_r($pwd);
?>

Output:

aced2dA6

Example 005. Multiple passwords

<?php
require_once 'Password.php';
$pwd = Password::getInstance()
       ->generate(32, 3);
print_r($pwd);
?>

Output:

Array
(
    [0] => IFnXkOtMx3hC773QyGURytuBSI106J3c
    [1] => oyj35PiskMLk0H2w9d98PMOxpNE6ZPmE
    [2] => Xn16sNEl4SY4zkUto0JiJI0iqIa25pAv
)

Example 006. Multiple passwords with custom alphabet, dictionary, custom length and only in lowercase

<?php
require_once 'Password.php';
$pwd = Password::getInstance()
       ->setAlphabet(array('a'), array('b'))
       ->setDictionary('passwords')
       ->generate(32, 3, Password::LOWER);
print_r($pwd);
?>

Output:

Array
(
    [0] => c1ralbaba2a0a0ab
    [1] => 6heat1abab8baba9
    [2] => b0igeba831ababab
)

Example 007. Silly random bitfields (contain only digits 0 and 1)

<?php
require_once 'Password.php';
$pwd = Password::getInstance()
       ->setAlphabet(array(0, 1))
       ->setDictionary()
       ->generate(array(32, 0), 3));
print_r($pwd);
?>

Output:

Array
(
    [0] => 01100111101110101110110000111101
    [1] => 11011001000111011101110001111000
    [2] => 10000101011111011111101111101011
)