Giter VIP home page Giter VIP logo

haveibeenpwned's Introduction

HaveIBeenPwned PHP client

Build Status

Install

{
    "require": {
        "xsist10/haveibeenpwned": "~1.0"
    }
}

Usage

Create manager instance

use xsist10\HaveIBeenPwned\HaveIBeenPwned;
use xsist10\HaveIBeenPwned\Adapter\Curl;
use xsist10\HaveIBeenPwned\Adapter\FileGetContents;

// By default the $manager will use a Curl adapter
$manager = new HaveIBeenPwned();

// You can create a new manager with a specified adapter
$manager = new HaveIBeenPwned(new Curl());

// You can also set the adapter after creation
$manager->setAdapter(new FileGetContents());

Check if you've been pwned

$manager->checkAccount("your_email_address");

Check if your account has been leaked in a paste

$manager->getPasteAccount("your_email_address");

Check if your password has been leaked before

// Your password is not sent to the remote API. Only a partial of the SHA1
// value is sent and all matching full SHA1 results are returned and compared.
$numberOfTimesCompromised = $manager->isPasswordCompromised("your_password");

List all breaches that have are on record

$manager->getBreaches();

$manager->getBreach('specific_breach_by_name');

List the types of data that are covered when describing a leak

$manager->getDataClasses();

Logger Support

The adapters support PSR-3 Logger. I recommend using monolog.

Install Monolog

$ composer require monolog/monolog

Use Monolog with HaveIBeenPwned

use xsist10\HaveIBeenPwned\HaveIBeenPwned;
use xsist10\HaveIBeenPwned\Adapter\Curl;

use Monolog\Logger;
use Monolog\Handler\StreamHandler;

$log = new Logger('name');
// Push all logging up to the level of DEBUG to our log file
$log->pushHandler(new StreamHandler('[full log filename]', Logger::DEBUG));

$adapter = new Curl();
$adapter->setLogger($log);
$manager = new HaveIBeenPwned($adapter);

// Calls made to HaveIBeenPwned will be logged to your log file now

Credits

License

The MIT License (MIT). Please see License File for more information.

haveibeenpwned's People

Contributors

peter279k avatar xsist10 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.