tp5 使用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';
} 使用谷歌验证可以大大加强网站的安全,我的这个网站就是使用了此功能 该谷歌验证是基于时间的,根据时间的变化而改变 本站文章如未注明出处均为原创,转载请注明出处,如有侵权请邮件联系站长。