Package 

Class TOTP


  • 
    public final class TOTP
    
                        

    Generates 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
      int generate(int timestamp, boolean withPadding) Generates the one time password.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 password
        digits - length of the password; acceptable values are 6, 7 or 8 otherwise an exceptionwill be thrown
        timeInterval - 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 seconds
        withPadding - trueorfalse if the end should include padded zeros