unique/was-password-pwned

A small tool to check if a password has been leaked against haveibeenpwned.com database.

dev-master 2021-02-20 16:36 UTC

This package is auto-updated.

Last update: 2024-09-21 00:29:04 UTC


README

A small tool to check if a password has been leaked against haveibeenpwned.com database.

Installation

This component requires php >= 7.4. To install it, you can use composer:

composer require unique/was-password-pwned

Usage

    $checker = new PasswordChecker();
    $count = $checker->checkIfPasswordPwned( sha1( 'my-password' ) );
    if ( $count ) {

        echo 'Your password has been leaked and found in ' . $count . ' databases.';
    } elseif ( $count === null ) {

        if ( $checker->getLastException() ) {

            echo (string) $checker->getLastException();
        } else {

            echo 'An error has occured.';
        }
    }

haveibeenpwned.com usage and license

Please read https://haveibeenpwned.com/API/v3#AcceptableUse for acceptable use of haveibeenpwned.com service and attribute it according to the author: https://haveibeenpwned.com/API/v3#License.