Skip to content
Projets

Jord-JD/password_exposed

Voir sur GitHub

Ă€ propos

đź”’ Password Exposed Helper Function - Check if a password has been exposed in a data breach.

Sécurité et confidentialité

Comment ces chiffres sont mesurés

Progression mesurée des étoiles

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
Historique en cours

Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.

README.md

Original

đź”’ Password Exposed Helper Function

This PHP package provides a password_exposed helper function, that uses the haveibeenpwned.com API to check if a password has been exposed in a data breach.

It supports PHP 7.1 through current releases. On PHP 8 it can use the PSR-6 v4 cache adapter required by modern frameworks, while PHP 7 installations continue to resolve the compatible v3 adapter.

Unit tests PHP syntax

CI is run via GitHub Actions (unit tests, Psalm, and PHP syntax checks).

Installation

The password_exposed package can be easily installed using Composer. Just run the following command from the root of your project.

composer require "jord-jd/password_exposed"

If you have never used the Composer dependency manager before, head to the Composer website for more information on how to get started.

Usage

To check if a password has been exposed in a data breach, just pass it to the password_exposed method.

Here is a basic usage example:

switch(password_exposed('hunter2')) {

    case PasswordStatus::EXPOSED:
        // Password has been exposed in a data breach.
        break;

    case PasswordStatus::NOT_EXPOSED:
        // Password has not been exposed in a known data breach.
        break;

    case PasswordStatus::UNKNOWN:
        // Unable to check password due to an API error.
        break;
}

If you prefer to avoid using helper functions, the following syntax is also available.

$passwordStatus = (new PasswordExposedChecker())->passwordExposed($password);

SHA1 Hash

You can also supply the SHA1 hash instead of the plain text password, by using the following method.

$passwordStatus = (new PasswordExposedChecker())->passwordExposedByHash($hash);

or...

$passwordStatus = password_exposed_by_hash($hash);

Explorer des projets similaires

Chargement…