Password hash validator / password requirements validator
You can install the package via composer:
composer require tleckie/password
require_once "vendor/autoload.php";
use Tleckie\Password\Validator;
use Tleckie\Password\Requirements;
$passwordManager = new Validator();
$validatePasswordForRegistration = 'Secure123.Validator';
//Check if the password meets the requirements to store it.
$passwordManager->isValid($validatePasswordForRegistration); // true
// You can customize the password requirements
$requirements = new Requirements(10, false, true, false, true);
$passwordManager = new Validator($requirements);
// Generate the hash to be stored in the database (user|hash).
$storeInDataBase = $passwordManager->createHash($validatePasswordForRegistration);
// User registration completed!
require_once "vendor/autoload.php";
use Tleckie\Password\Validator;
$passwordManager = new Validator();
// Find the user when logging in.
$loginPassword = 'Secure123.Validator';
$databaseUserHash = '$2y$08$WiqPWg.Gkd1CPVpCn/izl.DxhAeJCeo8SVpV03vBCb04.OgMEF81m';
// We verify the hash stored in the database with the login passwords
$passwordManager->passwordVerify($loginPassword, $databaseUserHash); // true
// That's all! I hope this helps you