限时免费试用:欢迎注册 api.bigmodel.org ,快速体验大模型 API 接入服务。
当前位置:首页 >开发者 >PHP笔记 >PHP高级

tp5 使用googleauthenticator 谷歌验证

分类:PHP高级时间:2019-07-02浏览:4689
下载扩展 https://packagist.org/packages/phpgangsta/googleauthenticator 使用:
createSecret();
echo "Secret is: ".$secret."\n\n";

//当前blog 你可以随意设置,唯一值
$qrCodeUrl = $ga->getQRCodeGoogleUrl('Blog', $secret);
echo "Google Charts URL for the QR-Code: ".$qrCodeUrl."\n\n";

//获取code码
$oneCode = $ga->getCode($secret);
echo "Checking Code '$oneCode' and Secret '$secret':\n";

//判断code是否一致
$checkResult = $ga->verifyCode($secret, $oneCode, 2);    // 2 = 2*30sec clock tolerance
if ($checkResult) {
    echo 'OK';
} else {
    echo 'FAILED';
}
使用谷歌验证可以大大加强网站的安全,我的这个网站就是使用了此功能 该谷歌验证是基于时间的,根据时间的变化而改变
本站文章如未注明出处均为原创,转载请注明出处,如有侵权请邮件联系站长。
0/500
Share your thoughts respectfully.