PHP code example of mike-jg / pwned-api

1. Go to this page and download the library: Download mike-jg/pwned-api 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/ */

    

mike-jg / pwned-api example snippets



use PwnedApi\Client;

$client = new Client();

$password = sha1("P@ssw0rd");
$rangeResult = $client->searchByRange($password);

// Boolean: was this password found?
echo $rangeResult->wasFound();
// How many times this password was found in the database
echo $rangeResult->getCount();


use PwnedApi\Client;
   
$client = new Client();

$password = sha1("P@ssw0rd");
$rangeResult = $client->searchByPasswordHash($password);

// Boolean: was this password found?
echo $rangeResult->wasFound();
// How many times this password was found in the database
echo $rangeResult->getCount();


use PwnedApi\Client;

$client = new Client();
$client->setHttpClient(new GuzzleHttp\Client());