nsp-team/google-authenticator
Composer 安装命令:
composer require nsp-team/google-authenticator
包简介
Google Authenticator
README 文档
README
This is a php library ,Google Authenticator One-time Password Algorithm in PHP
- 相对于验证码,安全很多;几乎是不会存在破解的方法
- 验证码有时候无法识别,不方便操作
- 一机一码,不会存在账号盗用的问题
- 动态验证,每30秒生产一个验证码,安全更加保障
see: https://www.phpgangsta.de/2-faktor-authentifizierung-mit-dem-google-authenticator
Installation
This library is installable via composer
composer require nsp-team/google-authenticator
Usage
require_once "vendor/autoload.php";
use NspTeam\Authenticator\GoogleAuthenticator;
$ga = new GoogleAuthenticator();
$secret = $ga->createSecret();
echo "Secret is: ".$secret."\n\n";
$qrCodeUrl = $ga->getQRCodeGoogleUrl('Blog', $secret);
echo "Google Charts URL for the QR-Code: ".$qrCodeUrl."\n\n";
$oneCode = $ga->getCode($secret);
echo "Checking Code '$oneCode' and Secret '$secret':\n";
$checkResult = $ga->verifyCode($secret, $oneCode, 2); // 2 = 2*30sec clock tolerance
if ($checkResult) {
echo 'OK';
} else {
echo 'FAILED';
}
统计信息
- 总下载量: 11
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2021-12-02