Class OtpUtils

java.lang.Object
dev.vink.jtotp.OtpUtils

public class OtpUtils extends Object
Utility class for generating OTP (One-Time Password) URLs.

This class provides methods to create OTP URLs following the Key URI Format.

  • Field Details

    • SECRET

      public static String SECRET
      Key for the shared secret parameter in the OTP URL.
    • ISSUER

      public static String ISSUER
      Key for the issuer parameter in the OTP URL.
    • ALGORITHM

      public static String ALGORITHM
      Key for the algorithm parameter in the OTP URL.
    • PERIOD

      public static String PERIOD
      Key for the period parameter in the OTP URL.
    • DIGITS

      public static String DIGITS
      Key for the digits parameter in the OTP URL.
  • Method Details

    • createOtpUrl

      public static String createOtpUrl(String type, String label, Map<String,String> params)
      Creates an OTP URL based on the specified type, label, and parameters.
      Parameters:
      type - The type of OTP (e.g., currently "totp" is supported).
      label - The label for the OTP, typically in the format "Issuer:AccountName".
      params - A map of key-value pairs representing additional parameters for the OTP URL.
      Returns:
      A string representing the complete OTP URL.
      Throws:
      RuntimeException - If UTF-8 encoding is not supported.
      NullPointerException - If params provided is null.