huaweichenai / google-authenticator
基于Google Authenticator双因素身份验证实现动态码验证
Installs: 57
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/huaweichenai/google-authenticator
Requires
- php: >=5.5
This package is auto-updated.
Last update: 2025-09-19 04:13:34 UTC
README
Installation
composer require huaweichenai/google-authenticator
Usage:
- 1:创建密钥
$authenticator = new Authenticator(); $secret = $authenticator->createSecret();
- 2:获取手机端扫描二维码链接(用于手机端获取动态口令)
$authenticator = new Authenticator(); $qrCodeUrl = $authenticator->getQRCodeGoogleUrl('username', $secret, 'title');
不支持使用此方法,此方法向第三方分享了你的安全性,建议使用下面的方法获取二维码信息自行生成二维码
- 3:获取手机端扫描二维码的信息(使用此信息生成二维码用于手机端获取动态口令)
$authenticator = new Authenticator(); $authCode = $authenticator->getAuthCode('username', $secret, 'title');
- 4:动态口令认证
$authenticator = new Authenticator(); $verifyCode = $authenticator->verifyCode($secret, 'code验证码'); if (verifyCode) { echo '认证成功'; } else { echo '认证失败'; }