Generate, hash & verify secure password.
composer require "eureka/component-password"<?php
use Eureka\Component\Password\PasswordGenerator;
use Eureka\Component\Password\StringGenerator;
//~ Use service generator
$length = 16; // default
$alpha = 0.6; // default
$numeric = 0.2; // default
$special = 0.2; // default
$generator = new PasswordGenerator(
new StringGenerator()
);
$password = $generator->generate($length, $alpha, $numeric, $special);
echo $password->getPlain() . PHP_EOL;
echo $password->getHash() . PHP_EOL;<?php
use Eureka\Component\Password\Password;
//~ Just define password
$password = new Password('mySecretPassword');
echo $password->getHash() . PHP_EOL;
echo $password->getPlain() . PHP_EOL;<?php
use Eureka\Component\Password\PasswordChecker;
//~ Just define password
$passwordChecker = new PasswordChecker();
$passwordPlain = 'mypassword'; // From login form
$passwordHash = '...'; // Retrieved from db for example
echo 'Is valid password: ' . $passwordChecker->verify($passwordPlain, $passwordHash) . PHP_EOL;vendor/bin/console password/script/generator --helpwill output this:
Use : bin/console Eureka\Component\Password\Script\Generator [OPTION]...
OPTIONS:
-g, --generate Generate password
-l ARG, --length=ARG Password length
-a ARG, --ratio-alpha=ARG Alphabetic latin characters ratio
-n ARG, --ratio-numeric=ARG Numeric characters ratio
-o ARG, --ratio-other=ARG Other characters ratio
See the CONTRIBUTING file.
You can install project with the following command:
make installAnd update with the following command:
make updateNB: For the components, the composer.lock file is not committed.
You can run unit tests (with coverage) on your side with following command:
make php/testsYou can run integration tests (without coverage) on your side with following command:
make php/integrationFor prettier output (but without coverage), you can use the following command:
make php/testdox # run tests without coverage reports but with prettified outputYou also can run code style check with following commands:
make php/checkYou also can run code style fixes with following commands:
make php/fixYou can check if any explicit dependency is missing with the following command:
make php/depsTo perform a static analyze of your code (with phpstan, lvl 9 at default), you can use the following command:
make php/analyseTo ensure you code still compatible with current supported version at Deezer and futures versions of php, you need to run the following commands (both are required for full support):
Minimal supported version:
make php/min-compatibilityMaximal supported version:
make php/max-compatibilityAnd the last "helper" commands, you can run before commit and push, is:
make ci This project is currently under The MIT License (MIT). See LICENCE file for more information.