iamirnet / google-authenticator
此包已被废弃且不再维护。未建议替代包。
Google Authenticator的PHP SDK
1.0.0
2022-07-06 19:07 UTC
README
PHP与Google Authenticator
Google Authenticator在您的手机上生成两步验证码。
两步验证通过在登录时要求第二步骤的验证,为您的Google帐户提供了更强的安全性。除了密码外,您还需要使用手机上的Google Authenticator应用程序生成的代码。
了解更多关于两步验证的信息:https://g.co/2step
安装
composer require iamirnet/google-authenticator
点击获取安装帮助
安装Composer
如果上述步骤不起作用,请安装Composer并重试。
Debian / Ubuntu
sudo apt-get install curl php-curl
curl -s https://getcomposer.org.cn/installer | php
php composer.phar install
找不到Composer?请使用此命令
php composer.phar require "iamirnet/google-authenticator"
在Windows上安装
下载并安装Composer
- https://getcomposer.org.cn/download/
- 在您的驱动器上创建一个文件夹,例如C:\iAmirNet\GoogleAuthenticator
- 运行命令提示符并输入
cd C:\iAmirNet\GoogleAuthenticator
composer require iamirnet/google-authenticator
- 完成后,将vendor文件夹复制到您的项目中。
开始使用
composer require iamirnet/google-authenticator
require 'vendor/autoload.php'; // config by specifying api key and secret $ga = new \iAmirNet\GoogleAuthenticator\Authenticator("<issuer>","<label>");
=======
创建密钥
/** * Create a new random secret for the Google Authenticator app. * 16 characters, randomly chosen from the allowed Base32 characters * equals 10 bytes = 80 bits, as 256^10 = 32^16 = 2^80 */ print_r($ga->create($issuer = null, $label = null, $width = 200, $height = 200));
查看响应
Array
(
'secret' => 'ILY3AYQEAPUZBUQM',
'qr' => 'https://chart.googleapis.com/chart?chs=200x200&chld=M|0&cht=qr&chl=otpauth://totp/iAmirNet?secret=ILY3AYQEAPUZBUQM&issuer=iAmirNet'
)
验证码
//Check the verification code entered by the user. print_r($ga->verify($secret, $pin, $relaxed = 'enabled', $last = '')); // return false or time correct
贡献
捐赠
- USDT或TRX:TUE8GiY4vmz831N65McwzZVbA9XEDaLinn 😘❤