Class TimeBasedOTP


  • public class TimeBasedOTP
    extends Object
    TOTP: Time-based One-time Password Algorithm Based on http://tools.ietf.org/html/draft-mraihi-totp-timebased-06
    Since:
    Sep 20, 2010
    Author:
    Anil.Saldhana@redhat.com
    • Constructor Detail

      • TimeBasedOTP

        public TimeBasedOTP()
    • Method Detail

      • generateTOTP

        public static String generateTOTP​(String key,
                                          String time,
                                          int returnDigits)
                                   throws GeneralSecurityException
        This method generates an TOTP value for the given set of parameters.
        Parameters:
        key - the shared secret, HEX encoded
        time - a value that reflects a time
        returnDigits - number of digits to return
        Returns:
        A numeric String in base 10 that includes truncationDigits digits
        Throws:
        GeneralSecurityException
      • generateTOTP256

        public static String generateTOTP256​(String key,
                                             String time,
                                             int returnDigits)
                                      throws GeneralSecurityException
        This method generates an TOTP value for the given set of parameters.
        Parameters:
        key - the shared secret, HEX encoded
        time - a value that reflects a time
        returnDigits - number of digits to return
        Returns:
        A numeric String in base 10 that includes truncationDigits digits
        Throws:
        GeneralSecurityException
      • generateTOTP512

        public static String generateTOTP512​(String key,
                                             String time,
                                             int returnDigits)
                                      throws GeneralSecurityException
        This method generates an TOTP value for the given set of parameters.
        Parameters:
        key - the shared secret, HEX encoded
        time - a value that reflects a time
        returnDigits - number of digits to return
        Returns:
        A numeric String in base 10 that includes truncationDigits digits
        Throws:
        GeneralSecurityException
      • generateTOTP

        public static String generateTOTP​(String key,
                                          String time,
                                          int returnDigits,
                                          String crypto)
                                   throws GeneralSecurityException
        This method generates an TOTP value for the given set of parameters.
        Parameters:
        key - the shared secret, HEX encoded
        time - a value that reflects a time
        returnDigits - number of digits to return
        crypto - the crypto function to use
        Returns:
        A numeric String in base 10 that includes truncationDigits digits
        Throws:
        GeneralSecurityException