Class Hex

java.lang.Object
com.codename1.crypto.encoding.Hex

public final class Hex extends Object
Hexadecimal encoding and decoding. Output is always lowercase; input may be upper or lower case and may start with a 0x or 0X prefix.
  • Method Details

    • encode

      public static String encode(byte[] data)

      Encodes bytes as a lowercase hex string without a prefix.

      Parameters
      • data: the bytes to encode
      Returns

      two hex digits per byte

    • decode

      public static byte[] decode(String hex)

      Decodes a hex string, accepting an optional 0x/0X prefix and either case.

      Parameters
      • hex: the text to decode
      Returns

      the decoded bytes

      Throws
      • IllegalArgumentException: if the length is odd or a character is not a hex digit