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

通过安全秘钥通过二维码(图片地址就是Google Charts生成的可以直接打开)生成二维码样例地址(二维码是不让发):

http://p3.pstatp.com/large/pgc-image/bade464f1a854a939344be12aa2aab79

动态口令验证

require_once './PHPGangsta/GoogleAuthenticator.php';

?

$ga = new PHPGangsta_GoogleAuthenticator();

?

// 把提交的验证码和服务端上生成的验证码做对比

// $secret 服务端的 "安全密匙SecretKey"

// $oneCode 手机上看到的 "一次性验证码"

// 最后一个参数 为容差时间,这里是2 那么就是 2* 30 sec 一分钟.

$oneCode = '371922';

$secret = 'M5X3M4PGBQRFPUTY';

推荐阅读