It looks like you're new here. If you want to get involved, click one of these buttons!
maven dependencies
<dependency>
<groupId>de.taimos</groupId>
<artifactId>totp</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
</dependency>
private String getTotp(String totp) throws Exception {
try {
Base32 base32 = new Base32();
byte[] bytes = base32.decode(totp);
String hexKey = Hex.encodeHexString(bytes);
String previousKey = TOTP.getOTP(hexKey);
while (previousKey.equals(TOTP.getOTP(hexKey))) {
Thread.sleep(1000);
log.info("sleeping for a second to wait for next key . current is : " + TOTP.getOTP(hexKey));
}
System.out.println("The new key is :" + TOTP.getOTP(hexKey));
return TOTP.getOTP(hexKey);
} catch (Exception e) {
log.error("Exception occured --> ", e);
throw e;
}
}
Thank you pranksterguru for explaining