1. Go to this page and download the library: Download shamimstack/breach-php 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/ */
shamimstack / breach-php example snippets
use ShamimStack\BreachPHP\Facades\BreachPHP;
$result = BreachPHP::check('password123');
if ($result->isBreached()) {
echo $result->count();
}
use ShamimStack\BreachPHP\BreachPHP;
use ShamimStack\BreachPHP\Services\PasswordChecker;
use ShamimStack\BreachPHP\Providers\HibpProvider;
use ShamimStack\BreachPHP\Http\HttpClient;
use ShamimStack\BreachPHP\Http\RequestFactory;
use ShamimStack\BreachPHP\Hash\Sha1Hasher;
use ShamimStack\BreachPHP\Parsers\HibpParser;
use Http\Discovery\Psr18ClientDiscovery;
use Http\Discovery\Psr17FactoryDiscovery;
$client = Psr18ClientDiscovery::find();
$requestFactory = new RequestFactory(Psr17FactoryDiscovery::findRequestFactory());
$httpClient = new HttpClient($client, $requestFactory);
$checker = new PasswordChecker(
provider: new HibpProvider($httpClient, new HibpParser()),
hasher: new Sha1Hasher(),
);
$result = $checker->check('password123');
$result->isSafe();
use ShamimStack\BreachPHP\Rules\NotBreached;
'password' => [
'
use ShamimStack\BreachPHP\Rules\NotBreached;
'password' => [
'eared in a data breach.'),
];