divineomega/password_exposed

This package is abandoned and no longer maintained. The author suggests using the jord-jd/password_exposed package instead.

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.

Maintainers

👁 Jord-JD

Package info

github.com/Jord-JD/password_exposed

Wiki

pkg:composer/divineomega/password_exposed

Fund package maintenance!

DivineOmega

Statistics

Installs: 1 682 649

Dependents: 5

Suggesters: 0

Stars: 222

Open Issues: 3

v5.0.2 2026-02-15 21:45 UTC

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

LGPL-3.0-only f9d0e8879432f1e7cf80617b51c16c66071411c7


README

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.

👁 Image

👁 Unit tests
👁 PHP syntax
👁 Image

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);