, (*1)
laszlof/php-hibp
is an SDK which allows PHP developers to easily communicate with the API provided by HaveIBeenPwned.Com., (*2)
Requirements
How to install
composer require laszlof/php-hibp
Usage
Get a list of breaches for a specific acccount (username/email)
use Hibp\Hibp;
$account = 'you@yourdomain.com';
$breaches = Hibp::getBreaches($account);
Get a single breach by name
use Hibp\Hibp;
$name = 'Adobe';
$breach = Hibp::getBreach($account);
Get a list of sites that have been breached (optionally filtered by domain)
use Hibp\Hibp;
$breaches = Hibp::getBreachedSites();
$domain = 'adobe.com';
$breaches = Hibp::getBreachedSites($domain);
Get a list of the types of dataclasses
use Hibp\Hibp;
$dataClasses = Hibp::getDataClasses();
Get a list of pastes for a specific acccount (username/email)
use Hibp\Hibp;
$account = 'you@yourdomain.com';
$breaches = Hibp::getPastes($account);
Check if a password has been compromised.
use Hibp\Hibp;
$password = 'password123';
$isCompromised = Hibp::checkPassword($password);
// Optionally check with a password that IS a hash itself.
$password_is_a_hash = '5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8';
$isCompromised = Hibp::checkPassword($password_is_a_hash, true);
Links