ron-maxweb / pwned-passwords
此包已被弃用,不再维护。作者建议使用 mxrxdxn/pwned-passwords 包。
一个库,用于查询Troy Hunt的Pwned Passwords服务,以查看密码是否被包含在公开的泄露事件中。
v2.1.0
2021-08-24 18:26 UTC
Requires
- php: ^7.3 | ^8.0
- guzzlehttp/guzzle: ^6.3 | ^7.0
Requires (Dev)
- phpunit/phpunit: ^9.5
- symfony/var-dumper: ^5.3
This package is auto-updated.
Last update: 2021-09-20 16:31:19 UTC
README
一个库,用于查询Troy Hunt的Pwned Passwords服务,以查看密码是否被包含在公开的泄露事件中。
需求
- PHP >= 7.2
安装
通过Composer可以轻松安装PwnedPasswords。只需使用以下命令要求此包,然后即可开始使用。
composer require mxrxdxn/pwned-passwords
使用方法
要使用此库,您可以按以下方式操作。
require_once('vendor/autoload.php'); $pp = new PwnedPasswords\PwnedPasswords; $password = '123456789'; $insecure = $pp->isPwned($password); //returns true or false
isInsecure
方法将在密码在PwnedPasswords API中找到时返回true,如果没有找到则返回false。
如果您想建立自己的阈值(例如,如果密码被发现超过一次则显示警告,超过5次则显示错误),您可以像下面这样调用isPwned
方法。
$pp = new PwnedPasswords\PwnedPasswords; $password = '123456789'; $insecure = $pp->isPwned($password, true); if ($insecure) { echo 'Oh no — pwned!' . "\n"; echo sprintf('This password has been seen %d time%s before.', $insecure, ($insecure > 1 ? 's' : '')); } else { echo 'All good!'; }
问题
请自由使用GitHub问题跟踪器来发布您对此库有任何问题。