1. Go to this page and download the library: Download elcodedocle/chbspassgen 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/ */
elcodedocle / chbspassgen example snippets
$passwordGenerator = new synapp\info\tools\passwordgenerator\PasswordGenerator(); // Expects a dictionary generated from a source on a file named 'top10000.txt'
$password = $passwordGenerator->generatePassword(); // Generates a password with default settings
$entropy = $passwordGenerator->getEntropy(); // entropy of the last generated password (won't change unless you change settings)
// Here is a quick debrief on the class constructor parameters (See the phpdoc blocks for more info):
$passwordGenerator = new synapp\info\tools\passwordgenerator\PasswordGenerator(
// the dictionary
// (null defaults to new Dictionary($this->defaultDictionaryFilename,$minReadWordsWordSize))
// with $this->defaultDictionaryFilename set to 'top10000.txt'
$dictionary = null,
// set the level of entropy used when none is explicitly specified on the generatePassword() call
// (null defaults to $this->defaultLevel, set to 2)
$level = 2,
// a string of unique chars from where to randomly choose the password separator
// (null defaults to $this->defaultSeparator, set to ' ')
$separators = ' ',
// an ascending ordered array of ints containing the minimum entropies for each level
// (null defaults to $this->defaultMinEntropies, set to array(64,80,112,128))
$minEntropies = array(64,80,112,128),
// boolean, whether to use selected random variations on the password words to increase entropy
// defaults to true
$useVariations = false,
// (array of booleans which activate random variations on the words, increasing entropy.
// Valid keys: 'allcaps', 'capitalize', 'punctuate', 'addslashes'). Use null for defaults.
$variations = null,
// Minimum length of the words used to create the password
// (null defaults to $this->defaultMinWordSize, set to 4)
$minWordSize = 4,
// Minimum length of the words read from the dictionary source
// (null defaults to $this->defaultMinReadWordsWordSize, set to 4)
$minReadWordsWordSize = 4, //(minimum length of the words read from the Dictionary source)
// the pseudoaleatory random generator (new CryptoSecurePRNG() by default)
$prng = new synapp\info\tools\passwordgenerator\cryptosecureprng\CryptoSecurePRNG()
);
// generatePassword method takes almost the same parameters as the contructor:
$password = $passwordGenerator->generatePassword(
$dictionary = null, // use null to skip parameters (set to the current setting)
$minEntropy = null, // and here too, and anywhere else when you want to
$level = 1, // specify further parameters like this one
$separators = '_ -', // and this one
$useVariations = true, // and this one
$variations = array( // and this one too
'allcaps'=>true, // (BTW, this system also works in the constructor, where you can
'capitalize'=>true // specify some params and leave others to their defaults using null)
)
);
// getEntropy can return a pretty accurate estimate of the entropy of the last generated
// password, but can also be given a password and a set of parameters to extract its entropy
$entropy = $passwordGenerator->getEntropy(
$password,
$dictionary = null,
$variationsCount = null,
$lastOrSeparator = true,
$separatorsCount = null
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.