使用google authenticator(谷歌身份验证器)打造用户登录动态口令
来源:互联网 发布:开发企业软件平台 编辑:程序博客网 时间:2024/05/01 16:42
google authenticator php 服务端
使用php类
直接下载 https://github.com/PHPGangsta/GoogleAuthenticator/raw/master/PHPGangsta/GoogleAuthenticator.php
在自己的业务逻辑中引用此php类.
require_once '../PHPGangsta/GoogleAuthenticator.php';$ga = new PHPGangsta_GoogleAuthenticator();//创建一个新的"安全密匙SecretKey"//把本次的"安全密匙SecretKey" 入库,和账户关系绑定,客户端也是绑定这同一个"安全密匙SecretKey"$secret = $ga->createSecret();echo "安全密匙SecretKey: ".$secret."\n\n";$qrCodeUrl = $ga->getQRCodeGoogleUrl('www.iamle.com', $secret); //第一个参数是"标识",第二个参数为"安全密匙SecretKey" 生成二维码信息echo "Google Charts URL for the QR-Code: ".$qrCodeUrl."\n\n"; //Google Charts接口 生成的二维码图片,方便手机端扫描绑定安全密匙SecretKey$oneCode = $ga->getCode($secret); //服务端计算"一次性验证码"echo "服务端计算的验证码是:".$oneCode."\n\n";//把提交的验证码和服务端上生成的验证码做对比// $secret 服务端的 "安全密匙SecretKey"// $oneCode 手机上看到的 "一次性验证码"// 最后一个参数 为容差时间,这里是2 那么就是 2* 30 sec 一分钟.// 这里改成自己的业务逻辑$checkResult = $ga->verifyCode($secret, $oneCode, 2);if ($checkResult) { echo '匹配! OK';} else { echo '不匹配! FAILED';}
服务端例子:
安全密匙SecretKey: NI5RHMWOTBIY6KP4
Google Charts URL for the QR-Code: https://chart.googleapis.com/chart?chs=200×200&chld=M|0&cht=qr&chl=otpauth%3A%2F%2Ftotp%2Fwwek–www.iamle.com%3Fsecret%3DNI5RHMWOTBIY6KP4
服务端计算的验证码是:255466
匹配! OK
3、google authenticator 手机客户端
手机端安装
1、Android移动设备
在您手机的应用市场搜索“Google身份验证器”或“Google Authenticator”,下载安装即可。拥有Google身份验证器的市场有:Google Play;应用汇;安卓市场;百度移动应用;优亿市场;安智市场 等
2、iOS移动设备
进入应用市场,搜索“Google Authenticator”,下载安装即可。
3、其他平台:
- Windows Phone:点击这里
- WebOS:点击这里
- Symbian或者其他支持Java ME的设备:点击这里
iPhone端测试上面的例子
手机中的验证码 和 服务端的验证码 都是 255466 验证通过
0 0
- 使用google authenticator(谷歌身份验证器)打造用户登录动态口令
- 使用google authenticator打造运维平台的动态口令
- 使用google身份验证器实现动态口令验证
- google authenticator (双重身份验证器)的java使用
- Python计算谷歌身份验证器(google authenticator)的验证码
- google authenticator 配置动态密码登录
- 使用Google-Authenticator加强服务器SSH登录
- Linux下使用Google Authenticator配置SSH登录动态验证码
- 谷歌验证 (Google Authenticator) PHP版
- 安装google-authenticator实现动态密码
- 使用google authenticator为你提供一次一密的ssh登录(by quqi99)
- google-authenticator
- google-authenticator
- Google Authenticator
- 5.Authenticator(登录验证器)
- 用户登录(WINDOWS身份验证)
- Centos服务器安全配置SSH使用Google Authenticator二次验证
- Google Authenticator机制详解
- 使用libcurl作http请求线程卡在curl_multi_perform的问题
- 什么是适配器?
- 2016-11-23知识点
- Python中类定义的讲解
- JavaScript事件详解-zepto的事件实现(二)
- 使用google authenticator(谷歌身份验证器)打造用户登录动态口令
- VS2013/MFC编程入门之三(MFC应用程序框架分析)
- python 使用unittest 测试接口
- UIBarButtonSystemItem样式
- ACCP S1 C# 第十章上机练习
- C/C++练习2
- Jquery提示框效果(确认提示框)
- java GC 回收机制
- 【Netty源码分析】Netty服务端bind端口过程