snipershady/pwned-password-check

PHP实现免费API haveibeenpwned.com,易于使用

v1.0.0 2022-09-30 17:32 UTC

This package is auto-updated.

Last update: 2024-09-29 06:08:47 UTC


README

PHP实现免费API haveibeenpwned.com,易于使用

composer require snipershady/pwned-password-check

上下文

您想检查密码是否已被泄露(即密码在另一个网站上已被破解)以及是否安全使用。此检查可以作为注册表单等服务使用,例如,可能使用异步调用,按您的喜好。

use PwnedPassCheck\Service\PwnedPasswordCheckerService;

class fooClass(){
    public function checkIfPasswordHasBeenPowned(): string {
          $pownedPassChecker = new PwnedPasswordCheckerService();
          if(pownedPassChecker->hasPowned($password)){
            return json_encode(["powned" => true, "msg"=> "Your password has been powned and is unsafe"]);
          }
          return return json_encode(["powned" => false, "msg"=> "Your password was not been powned"]);
    }
}