Interface CodeGenerator


@AvailableSince("0.0.25") public interface CodeGenerator
  • Method Details

    • create

      static CodeGenerator create()
      Returns:
      The created code generator
    • create

      static CodeGenerator create(HashingAlgorithm algorithm, int digits) throws InvalidParameterException
      Parameters:
      algorithm - The hashing algorithm to use
      digits - The number of digits to generate (for example 6 means 000000 and 999999)
      Returns:
      The created code generator
      Throws:
      InvalidParameterException - If the algorithm or the number of digits is invalid
    • generate

      String generate(String secret, long counter) throws Exception
      Parameters:
      secret - The shared secret key to generate the code with
      counter - The current time bucket number (Number of seconds since epoch / bucket period)
      Returns:
      The n-digit code for the secret/counter.
      Throws:
      Exception