Class SecretGenerator

java.lang.Object
com.bastiaanjansen.otp.SecretGenerator

public class SecretGenerator
extends Object
A secret generator to generate OTP secrets
Author:
Bastiaan Jansen
  • Field Details

  • Constructor Details

  • Method Details

    • generate

      public static byte[] generate()
      Generate an OTP base32 secret with default amount of bits
      Returns:
      generated secret
    • generate

      public static byte[] generate​(int bits)
      Generate an OTP base32 secret
      Parameters:
      bits - length, this should match the length of the HMAC algorithm type: SHA1: 160 bits SHA256: 256 bits SHA512: 512 bits
      Returns:
      generated secret