Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.

public final class Hex

  1. Object
  2. Hex
Hexadecimal encoding and decoding. Output is always lowercase; input may be upper or lower case and may start with a 0x or 0X prefix.

Methods

public static String encode(byte[] data)Encodes bytes as a lowercase hex string without a prefix.
public static byte[] decode(String hex)Decodes a hex string, accepting an optional 0x/0X prefix and either case.

Inherited methods

Method details

encode

public static String encode(byte[] data)
Encodes bytes as a lowercase hex string without a prefix.

Parameters

data byte[]
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 String
the text to decode

Returns

the decoded bytes

Throws

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