Password, Please! generates secure passwords in PHP. You can use it as a command line application or as a library in your code.
Downloading the PHAR archive from the releases page page is the easiest way to get the command line application.
The other way is to clone this repository and execute the bin/password-please.php
file.
$ git clone https://github.com/florianeckerstorfer/passwordplease-php
$ cd password-please-php
$ php bin/password-please.php gen
If you call the binary without any arguments you will get a password of length 20 with lower and upper case letters, numbers and special characters. You can change both the length and the complexity.
$ php password-please.phar gen --length=30 --complexity=3
The length must be greather than 0
and complexity must be a value between 1
(very high complexity) and 4
(low complexity). If you're a hasty person, you can use the shorter aliases for the options:
$ php password-please.phar gen -l 30 -c 3
Instead of using the numeric identifier for the complexity, you can also use a high-level string description of the complexity. The following table details the available complexities, the characters used in it and the high-level names:
Complexity | Level | Alias | Characters |
---|---|---|---|
VERY_HIGH |
1 |
veryhigh , harder |
a-zA-Z0-9,;.:-_+*#!()=?%&@$"' |
HIGH |
2 |
high , hard |
a-zA-Z0-9 |
MEDIUM |
3 |
medium , normal |
a-zA-Z |
LOW |
4 |
low , easy |
a-z |
If you want to use Password, Please! in your code you can add the library to your dependencies using Composer.
$ composer require florianeckerstorfer/passwordplease-php:@stable
Tip: You should replace @stable
with a specific version from the releases page.
Password, Please! depends on ircmaxell/random-lib to generate passwords
and you need to pass an instance of \RandomLib\Generator
to the constructor.
use Fe\PasswordPlease\PasswordPlease;
$factory = new \RandomLib\Factory;
$generator = $factory->getGenerator(new \SecurityLib\Strength(\SecurityLib\Strength::MEDIUM));
$pp = new PasswordPlease($generator);
$password = $pp->generatePassword(30, PasswordPlease::COMPLEXITY_HIGH);
- Add string alias for complexities
- Change order of complexities,
1
is now very high and4
is low
- Initial release
Developed by Florian Eckerstorfer in Vienna, Europe.
The MIT license applies to florianeckerstorfer/passwordplease-php
. For the full copyright and license information, please view the LICENSE
file distributed with this source code.