php通过谷歌身份验证实现动态口令

php通过谷歌身份验证实现动态口令

Google Authenticator PHP类

https://github.com/PHPGangsta/GoogleAuthenticator

生成安全码并绑定手机

require_once './PHPGangsta/GoogleAuthenticator.php';

?

$ga = new PHPGangsta_GoogleAuthenticator();

?

// 创建新的"安全密匙SecretKey"

// 把本次的"安全密匙SecretKey" 入库,和账户关系绑定,客户端也是绑定这同一个"安全密匙SecretKey"

// 安全密匙SecretKey 可以和手机端绑定

$secret = $ga->createSecret();

?

echo "安全密匙SecretKey: " . $secret . "\n\n";

推荐阅读