Class HmacOTP

    • Constructor Detail

      • HmacOTP

        public HmacOTP​(int numberDigits,
                       String algorithm,
                       int delayWindow)
    • Method Detail

      • generateSecret

        public static String generateSecret​(int length)
      • generateHOTP

        public String generateHOTP​(String key,
                                   int counter)
      • validateHOTP

        public int validateHOTP​(String token,
                                String key,
                                int counter)
        Parameters:
        token -
        key -
        counter -
        Returns:
        -1 if not a match. A positive number means successful validation. This positive number is also the new value of the counter
      • generateOTP

        public String generateOTP​(String key,
                                  String counter,
                                  int returnDigits,
                                  String crypto)
        This method generates an OTP value for the given set of parameters.
        Parameters:
        key - the shared secret, HEX encoded
        counter - 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 return digits
        Throws:
        GeneralSecurityException