PHP code example of oldas / pwned-passwords
1. Go to this page and download the library: Download oldas/pwned-passwords 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/ */
oldas / pwned-passwords example snippets
use Oldas\PwnedPasswords\HaveIBeenPwnedService;
// Create a service instance
$haveIBeenPwnedService = new HaveIBeenPwnedService();
$plainTextPassword = 'password'; // leaked password
// Check if the password has been compromised
$result = $haveIBeenPwnedService->isPwned($plainTextPassword);
// Returns: true (if compromised), false (if safe), or null (in case of API timeout)
// Validate the password (throws exceptions for invalid input)
$haveIBeenPwnedService->validatePassword($plainTextPassword); // Throws InvalidPasswordInputException, otherwise returns void