java.lang.Object
org.seppiko.commons.utils.codec.Base36

public class Base36 extends Object
Base36 encoding and decoding.

Commonly used by URL redirection systems like TinyURL as compact alphanumeric identifiers.

Author:
Leonard Woo
See Also:
  • Method Details

    • encodeBytes

      public static String encodeBytes(byte[] data)
      Encode bytes to Base36 string
      Parameters:
      data - bytes.
      Returns:
      Base36 String.
    • encodeBytes

      public static String encodeBytes(byte[] data, boolean toLowercase)
      Encode bytes to Base36 string
      Parameters:
      data - bytes.
      toLowercase - true is return [0-9a-z], false is [0-9A-Z].
      Returns:
      Base36 String.
    • encode

      public static String encode(BigInteger source)
      Encode number to Base36 string
      Parameters:
      source - Number.
      Returns:
      Base36 String.
    • encode

      public static String encode(BigInteger source, boolean toLowercase)
      Encode number to Base36 string
      Parameters:
      source - Number.
      toLowercase - true is return [0-9a-z], false is [0-9A-Z].
      Returns:
      Base36 String.
    • decodeBytes

      public static byte[] decodeBytes(String str)
      Decode Base36 string to bytes
      Parameters:
      str - Base36 String.
      Returns:
      bytes.
    • decode

      public static BigInteger decode(String str)
      Decode Base36 string to number
      Parameters:
      str - Base36 String.
      Returns:
      Number.