-
Notifications
You must be signed in to change notification settings - Fork 28
/
Test.java
33 lines (28 loc) · 915 Bytes
/
Test.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package 双向认证;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
import 双向认证.LinAuthenication.OtpSourceException;
public class Test {
public static void main(String[] args) {
new Timer().scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
try {
//单纯输出时间
Date now = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");//可以方便地修改日期格式
String hehe = dateFormat.format( now );
System.out.println(hehe);
//测试算法
String secret = "abcdefghijklmnopqrst";
String result = LinAuthenication.getCurrentCode(secret);
System.out.println(result);
} catch (OtpSourceException e) {
e.printStackTrace();
}
}
}, 0, 1000);
}
}