PHP code example of kristos80 / password-generator

1. Go to this page and download the library: Download kristos80/password-generator 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/ */

    

kristos80 / password-generator example snippets


use Kristos80\PasswordGenerator\PasswordGenerator;
use Kristos80\PasswordGenerator\PasswordGeneratorFactory;

$config = PasswordGeneratorConfigFactory::safeDefault();
$password = (new PasswordGenerator())->generate($config);

echo $password;

use Kristos80\PasswordGenerator\PasswordGeneratorConfig;
use Kristos80\PasswordGenerator\PoolRange;

$config = new PasswordGeneratorConfig(
    new PoolRange(3, 5),   // lowercase
    new PoolRange(2, 4),   // uppercase
    new PoolRange(2, 2),   // numbers
    new PoolRange(1, 2),   // symbols
    true,                  // must start with a letter
    ['l', '1', '0', 'O']   // characters to exclude
);

$password = (new PasswordGenerator())->generate($config);