Giter VIP home page Giter VIP logo

php-pwned-passwords's Introduction

PHP Pwned Passwords

Latest Stable Version REUSE compliant Minimum PHP Version Unit tests Coverage Status License

A PHP library for the Pwned Passwords's API from Troy Hunt's Have I Been Pwned project.

The main feature compare to others is that you can configure your own API endpoint if don't want to use HIBP's API.

Table of Contents

What about security of the Pwned Password API ?

Testing real passwords on a remote API ? What about security and privacy ?

You don't send the password to the API, only the first 5 characters of the SHA1 password's hash are sent to the endpoint API. It's the implementation of a mathematical property called k-anonymity.

Not enough for you ? You can build your own API by using this Golang project :

  • to build an optimized binary file from the official database files
  • to run an httpd handler who reproduce the HIBP Pwned Password API.

This PHP Pwned Passwords lib permit you to change the API endpoint.

Read more about :

Install

composer require univ-rennes2/pwned-passwords

Usage

<?php

declare(strict_types=1);

require_once __DIR__ . '/vendor/autoload.php';

use UniversiteRennes2\PwnedPasswords\PwnedPasswords;

$PPApi = new PwnedPasswords();

// Set new URI for API if have local API server (like this API server in Golang : <https://github.com/tylerchr/pwnedpass>)
// default is set to Troy Hunt's API.
// $PPApi->setApiUrl('http://127.0.0.1:3000/range');

$password = '123456';

// Just test of pwned or not
if ($PPApi->isPwned($password)) {
    // Pwned password
    printf("%s have been pwned\n", $password);
} else {
    // Not Pwned password
    printf("%s have NOT been pwned\n", $password);
}

// To knows how many times it have been pwned
$pwned = $PPApi->howManyPwned($password);
if ($pwned > 0) {
    // Pwned
    printf("%s have been pwned %s times\n", $password, $pwned);
} else {
    // Not pwned
    printf("%s have NOT been pwned\n");
}

Contribute

See CONTRIBUTING.md

License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License v3.0 or later as published by the Free Software Foundation.

The program in this repository meet the requirements to be REUSE compliant, meaning its license and copyright is expressed in such as way so that it can be read by both humans and computers alike.

For more information, see https://reuse.software/

php-pwned-passwords's People

Contributors

zeuh avatar

Watchers

 avatar  avatar  avatar

php-pwned-passwords's Issues

PHP Notice

Received by email from Lothar.B

PHP Notice: Undefined offset: 1 in /vendor/univ-rennes2/pwned-passwords/src/PwnedPasswords.php on line 149

The source code line 149 is:
[$resSuffix, $resCount] = explode(':', trim($line));

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.