重要的事情写在前面:

一定要保存好你的secret和恢复码!!登录的时候会用到!!!!

一定要保存好你的secret和恢复码!!登录的时候会用到!!!!

一定要保存好你的secret和恢复码!!登录的时候会用到!!!!

 第一步:引依赖

com.amdelamar

jotp

1.3.0

第二步 生成OTP

1.取到密钥 

2.

      将代码中secret部分替成刚刚取到的密钥,生成code! 一定要保存好secret!!

public static void main(String[] args) throws IOException, NoSuchAlgorithmException, InvalidKeyException {

// Generate a Time-based OTP from the secret, using Unix-time

// rounded down to the nearest 30 seconds.

String hexTime = OTP.timeInHex(System.currentTimeMillis(), 30);

String code = OTP.create(secret, hexTime, 6, Type.TOTP);

System.out.println(code);

}

第三步.使用code

将控制台打印的code填入github输入框即可成功到达认证第二步,下载保存这些恢复码!(一定要保存好!),即可完成认证! 一定要保存好这些恢复码

 这里看到已经开启2FA啦

一起来试试是否成功.

将代码生成的授权码输入进去可以看到已经登录成功啦!

 

推荐阅读

评论可见,请评论后查看内容,谢谢!!!
 您阅读本篇文章共花了: