Class Base36Or62

java.lang.Object
ai.bizone.shortuuid.Base36Or62

public class Base36Or62 extends Object
Base36Or62 is a utility class that provides methods to encode and decode numbers using Base36 or Base62 encoding.
  • Field Details

  • Constructor Details

    • Base36Or62

      public Base36Or62()
  • Method Details

    • encode

      static String encode(BigInteger number, boolean base62)
      Encodes a number using Base36 encoding.
      Parameters:
      number - a positive integer
      base62 - whether to use Base62 or Base36
      Returns:
      a Base36 string
      Throws:
      IllegalArgumentException - if number is a negative integer
    • decode

      static BigInteger decode(String string, boolean base62, int bitLimit)
      Decodes a string using Base36 encoding.
      Parameters:
      string - a Base36 string
      base62 - whether to use Base62 or Base36
      bitLimit - amount of bits the number is allowed to have
      Returns:
      a positive integer
      Throws:
      IllegalArgumentException - if string is empty