一个简单的类,允许用户轻松地检查pwndpassword列表

1.0.0 2021-02-23 13:47 UTC

This package is auto-updated.

Last update: 2024-09-29 01:58:24 UTC


README

用于检查密码与HIBP API的PHP包

用法

使用composer安装并直接使用类... 没有什么特别的

composer require finlaydag33k\hibp


use FinlayDaG33k\HIBP\HIBP;

// Prepare the password
$password = "lamepassword";
$hash = Security::hash($password, 'sha1', false);
$sub5 = substr($hash, 0, 5);

// Get a list of hashes
$hashes = (new HIBP())->checkPassword($sub5);

// Check if the "remainder" of the hash exists in our dataset
$results = array_filter($hashes, function ($row) use ($hashes, $hash) {
  return strpos($row, strtoupper(substr($hash, 5))) !== false;
});
$compromised = (count($results) > 0);
var_dump($compromised); // bool(true)