The compiled libraries are deployed to Maven Central.
With maven:
<dependency>
<groupId>io.github.kamilszewc</groupId>
<artifactId>totp</artifactId>
<version>6.0</version>
</dependency>
With gradle:
implementation 'io.github.kamilszewc:totp:6.0'
It requires Java 8.
Getting totp code (defult settings):
String code = Totp.getCode(secret);
Getting the ramaining validity time of totp code (default settings):
long remainingValidityTime = Totp.getRemainingValidityTime();
There is also an option to generate custom codes:
String code = Totp.getCode(
secret, // Secret password
epoch, // Epoch (default 0)
timeStep, // Length of password validity in seconds (default 30)
timeStamp, // Time stamp (Unix time) (default now)
codeLength, // Length of returned code (between 1 and 9, default 6)
hashFunction); // Hash function (default sha1)