安装:
composer require sonata-project/google-authenticator
使用:
<?php // 1. 引入包 require_once "vendor/autoload.php"; // 2. 使用命名空间 use Sonata\GoogleAuthenticator\GoogleAuthenticator; // 3. 实例化类 $obj = new GoogleAuthenticator(); // 4. 生成密钥 $secret = $obj->generateSecret(); // 5. 根据密钥生成验证码 $code = $obj->getCode($secret); // 6. 验证验证码的有效性 $is_valid = $obj->checkCode($secret,$code);
客户端:
- 安装:
- 添加密钥:
- 效果:
- 安装:
文档更新时间: 2024-04-20 10:57 作者:lee