-
public final class TOTPGenerates a Time-based one time password.
-
-
Constructor Summary
Constructors Constructor Description TOTP(ByteBuffer secret, int digits, int timeInterval, OTPAlgorithm algorithm)Sets up how we will generate the password
-
Method Summary
Modifier and Type Method Description intgenerate(int timestamp, boolean withPadding)Generates the one time password. -
-
Constructor Detail
-
TOTP
TOTP(ByteBuffer secret, int digits, int timeInterval, OTPAlgorithm algorithm)
Sets up how we will generate the password- Parameters:
secret- ByteBuffer wrapping the secret to encode into the passworddigits- length of the password; acceptable values are 6, 7 or 8 otherwise an exceptionwill be throwntimeInterval- time interval for the generation of the password (i.algorithm- OTPAlgorithm HMAC algorithm to use when hashing the secret (SHA1,SHA256 & SHA512 are supported)
-
-
Method Detail
-
generate
int generate(int timestamp, boolean withPadding)
Generates the one time password.
- Parameters:
timestamp- time since 1970 in secondswithPadding-trueorfalseif the end should include padded zeros
-
-
-
-