限时免费试用:欢迎注册 api.bigmodel.org ,快速体验大模型 API 接入服务。

PHP高级

tp5 使用googleauthenticator 谷歌验证

下载扩展 https://packagist.org/packages/phpgangsta/googleauthenticator 使用:

作者
王明昌
发布时间
最后更新
下载扩展 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
友善分享您的看法。
反馈邮箱