Memorable password generator, inspired by a PERL module powering xkpasswd.net/s/
Based heavily on the xkpasswd-node package. Also a nod to battery-staple for the inspiration.
composer require adgodev/xkpasswd-phpYou can use xkpasswd as a module in your application.
EXAMPLES
use Adgodev\Xkpasswd\PasswordGenerator;
PasswordGenerator::generate();
// valuable=bear=difference=53
PasswordGenerator::generate([
'complexity' => 5,
'separators' => '#+-'
]);
// addition#wheat#congress#manner#lonely#20
PasswordGenerator::generate([
'wordList' => 'myWordList.json'
]);
// apple#grape#banana#40You can specify complexity argument in accordance with complexity levels table. Defaults to 2.
If specified pattern argument overrides the pattern derived from complexity level.
If separators are provided they are used instead of the standard set (see complexity levels).
One separator is used per password, picked randomly from the provided set.
You can set transform option to alternate or uppercase to trigger case transformation.
Finally if you'd like to use a custom list of words you can provide it
as a JSON file, text file or an array via wordList function.
EXAMPLE Default behaviour
use Adgodev\Xkpasswd\PasswordGenerator;
PasswordGenerator::generate();
// hide+threw+money+61EXAMPLE Specify complexity
use Adgodev\Xkpasswd\PasswordGenerator;
PasswordGenerator::generate([
'complexity' => 5
]);
// join=industrial=wide=direction=lungs=16
PasswordGenerator::generate([
'complexity' => 6
]);
// 57!FIFTHLY!astronauts!AFFECTEDLY!nymphs!TRUSTLESSNESSES!06EXAMPLE Specify custom pattern
use Adgodev\Xkpasswd\PasswordGenerator;
PasswordGenerator::generate([
'pattern' => 'wdwd'
]);
// adjective3solar6EXAMPLE Specify custom word list / dictionary
use Adgodev\Xkpasswd\PasswordGenerator;
PasswordGenerator::generate([
'wordList' => 'myWordList.json'
]);
// orange.apple.bananause Adgodev\Xkpasswd\PasswordGenerator;
PasswordGenerator::generate([
'wordList' => 'myWordList.txt'
]);
// kiwi-strawberry-grapePatterns can consist of any combination of words, digits and separators. The first letters (w, d and s respectively) are used in pattern string provided to the password generation function.
For example:
wwill return a single word (i.e.demographics). Usewfor lowercase andWfor uppercase.wsdwill return a word and a digit, separated by one of the permitted separators (i.e.storm#7)wswsddwill return two words followed by a two digit number, all with separators between (i.e.delates+dissembled+16)
There are 6 complexity levels specified which can be used to provide default patterns as well as trigger additional features, such as alternate casing between words and expanded sets of separators.
| Complexity | Pattern | Separators |
|---|---|---|
| 1 | wsw | #.-=+_ |
| 2 | wswsw | #.-=+_ |
| 3 | wswswsdd | #.-=+_ |
| 4 | wswswswsdd | #.-=+_ |
| 5 | wswswswswsd | #.-=+_!$*:~? |
| 6 | ddswswswswswsdd | #.-=+_!$*:~?%^&; |
In addition level 6 alternates upper and lower case between words.
v1.0.0
Initial release