1. Go to this page and download the library: Download darkstrata/credential-check 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/ */
darkstrata / credential-check example snippets
arkStrata\CredentialCheck\Client;
use DarkStrata\CredentialCheck\Crypto;
$client = new Client(['apiKey' => getenv('DARKSTRATA_API_KEY')]);
// $email and $password come from your login form and are only ever used here.
// 1. Hash the credential locally: SHA-256 of "email:password".
// The plaintext email and password never leave this process.
$hash = Crypto::hashCredential($email, $password);
// 2. Check the hash. The SDK sends only the first 5 characters (the
// k-anonymity prefix) to the API and compares the full hash locally.
$result = $client->checkHash($hash);
if ($result->found) {
echo "WARNING: Credential found in breach!";
} else {
echo "OK: Credential not found in known breaches";
}
use DarkStrata\CredentialCheck\Laravel\NotCompromisedCredential;
// Registration or reset: the email is read from the same request
$request->validate([
'email' => ['tly
$request->validate([
'password' => ['
use DarkStrata\CredentialCheck\Laravel\CompromisedCredentialDetected;
Event::listen(CompromisedCredentialDetected::class, function (CompromisedCredentialDetected $event) {
// $event->source: 'login' or 'password'
// $event->email, $event->userId
// e.g. notify the security team, force a reset, lock the account
});