public class HexUtils extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
HexUtils.DecoderException |
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
decodeHex(char[] data)
Converts an array of characters representing hexadecimal values into an array of bytes of those same values.
|
static byte[] |
decodeHex(String string)
Converts a String or an array of character bytes representing hexadecimal values into an array of bytes of those
same values.
|
static char[] |
encodeHex(byte[] data)
Converts an array of bytes into an array of characters representing the hexadecimal values of each byte in order.
|
static char[] |
encodeHex(byte[] data,
boolean toLowerCase)
Converts an array of bytes into an array of characters representing the hexadecimal values of each byte in order.
|
protected static char[] |
encodeHex(byte[] data,
char[] toDigits)
Converts an array of bytes into an array of characters representing the hexadecimal values of each byte in order.
|
static String |
encodeHexString(byte[] data)
Converts an array of bytes into a String representing the hexadecimal values of each byte in order.
|
protected static int |
toDigit(char ch,
int index)
Converts a hexadecimal character to an integer.
|
public static byte[] decodeHex(char[] data)
throws HexUtils.DecoderException
data - An array of characters containing hexadecimal digitsHexUtils.DecoderException - Thrown if an odd number or illegal of characters is suppliedpublic static byte[] decodeHex(String string) throws HexUtils.DecoderException
string - A String or, an array of character bytes containing hexadecimal digitsHexUtils.DecoderException - Thrown if an odd number of characters is supplied to this function or the object is not a String or
char[]decodeHex(char[])protected static int toDigit(char ch,
int index)
throws HexUtils.DecoderException
ch - A character to convert to an integer digitindex - The index of the character in the sourceHexUtils.DecoderException - Thrown if ch is an illegal hex characterpublic static char[] encodeHex(byte[] data)
data - a byte[] to convert to Hex characterspublic static char[] encodeHex(byte[] data,
boolean toLowerCase)
data - a byte[] to convert to Hex characterstoLowerCase - true converts to lowercase, false to uppercaseprotected static char[] encodeHex(byte[] data,
char[] toDigits)
data - a byte[] to convert to Hex characterstoDigits - the output alphabetpublic static String encodeHexString(byte[] data)
data - a byte[] to convert to Hex charactersCopyright © 2018. All rights reserved.