Package libcore.util
Class HexEncoding
- java.lang.Object
-
- libcore.util.HexEncoding
-
public class HexEncoding extends Object
Hexadecimal encoding where each byte is represented by two hexadecimal digits.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]decode(char[] encoded, boolean allowSingleChar)Decodes the provided hexadecimal string into a byte array.static char[]encode(byte[] data)Encodes the provided data as a sequence of hexadecimal characters.static char[]encode(byte[] data, int offset, int len)Encodes the provided data as a sequence of hexadecimal characters.
-
-
-
Method Detail
-
encode
public static char[] encode(byte[] data)
Encodes the provided data as a sequence of hexadecimal characters.
-
encode
public static char[] encode(byte[] data, int offset, int len)Encodes the provided data as a sequence of hexadecimal characters.
-
decode
public static byte[] decode(char[] encoded, boolean allowSingleChar) throws IllegalArgumentExceptionDecodes the provided hexadecimal string into a byte array. IfallowSingleCharistrueodd-length inputs are allowed and the first character is interpreted as the lower bits of the first result byte. Throws anIllegalArgumentExceptionif the input is malformed.- Throws:
IllegalArgumentException
-
-