代码的方式解决Github的2FA验证

71 阅读1分钟

原文链接:blog.csdn.net/dejavu_9803…

依赖:

<dependency>  
<groupId>com.amdelamar</groupId>  
<artifactId>jotp</artifactId>  
<version>1.3.0</version>  
</dependency>

代码:

public static void main(String[] args) throws IOException, NoSuchAlgorithmException, InvalidKeyException {  
//这里替换为自己的
String secret="XXXXXXXXXXXXXX";  
  
String hexTime = OTP.timeInHex(System.currentTimeMillis(), 30);  
String code = OTP.create(secret, hexTime, 6, Type.TOTP);  
System.out.println(code);  
}

image.png