And*_*per 2 java android erlang-otp
登录认证系统中的OTP号是多少?有没有使用java(android)生成OTP号码的特定算法.或者是OTP类似随机数?如何通过优化实现这一目标.
cor*_*nux 17
请不要重新发明轮子 - 特别是在安全和加密的情况下.你可能最终处于一个非常糟糕的状态.
使用社区同意的算法,如Open Authentication Iniative指定的HOTP和TOTP算法.这些算法也由Google身份验证器使用,并在这些RFC中指定.读它们.它们很简单.
http://tools.ietf.org/html/rfc4226
https://tools.ietf.org/html/rfc6238
检查谷歌身份验证器。:https : //github.com/google/google-authenticator它是具有 OTP 功能的开源项目
Android 应用程序的源代码https://code.google.com/p/google-authenticator/source/browse/?repo=android
这是服务器端的源代码https://github.com/chregu/GoogleAuthenticator.php
维基百科文章http://en.wikipedia.org/wiki/Time-based_One-time_Password_Algorithm
最简单的方法是将 DecimalFormat 与 Random 类一起使用。
String otp= new DecimalFormat("000000").format(new Random().nextInt(999999));
System.out.println(otp);
Run Code Online (Sandbox Code Playgroud)
样本输出,
002428
445307
409185
989828
794486
213934
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
55120 次 |
| 最近记录: |