PHP code example of ballen / plexity
1. Go to this page and download the library: Download ballen/plexity 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/ */
ballen / plexity example snippets
use Ballen\Plexity\Plexity as PasswordValidator;
$password = new PasswordValidator();
$password->rs.
->NumericChataters(3); // We want to ensure that the password uses at least 3 numbers!
// An example of passing a password history array, if the password exists in here then we'll disallow it!
$password->notIn([
'test_password',
'Ros3bud',
'mypasSwordh88e8*&|re',
]);
// You can optionally pass in an implementation of PasswordHistoryInterface like so:
//$password->notIn(new CustomPasswordHistoryDatastore()); // Must implement Ballen\Plexity\Interfaces\PasswordHistoryInterface
try {
$password->check('my_password_string_here');
echo "Great news! The password passed validation!";
} catch (Ballen\Plexity\Exceptions\ValidationException $exception) {
die('Password was invalid, the error was: ' . $exception->getMessage());
}