Top Description Fields Constructors Methods
io.undertow.util

public Class HexConverter

extends Object
Class Inheritance
Static Imports
org.wildfly.common.Assert.checkNotNullParamWithNullPointerException

A utility class for mapping between byte arrays and their hex representation and back again.
Author
Darran Lofthouse

Field Summary

Modifier and TypeField and Description
private static final byte[]
private static final char[]

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static byte[]

Returns:

the raw byte array.
convertFromHex
(final char[]
- the hex encoded String to convert.
toConvert
)

Take the incoming character of hex encoded data and convert to the raw byte values.

public static byte[]

Returns:

the raw byte array.
convertFromHex
(final String
- the hex encoded String to convert.
toConvert
)

Take the incoming String of hex encoded data and convert to the raw byte values.

public static byte[]

Returns:

the encoded byte array.
convertToHexBytes
(byte[]
- the bytes to be encoded.
toBeConverted
)

Take the supplied byte array and convert it to to a byte array of the encoded hex values.

public static String

Returns:

the hex encoded String.
convertToHexString
(byte[]
- the bytes to be converted.
toBeConverted
)

Take the supplied byte array and convert it to a hex encoded String.

public static void
main(String[] args)

private static byte
toByte(final char[] toConvert, final int pos)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

HEX_BYTESback to summary
private static final byte[] HEX_BYTES
HEX_CHARSback to summary
private static final char[] HEX_CHARS

Constructor Detail

HexConverterback to summary
public HexConverter()

Method Detail

convertFromHexback to summary
public static byte[] convertFromHex(final char[] toConvert)

Take the incoming character of hex encoded data and convert to the raw byte values.

The characters in the incoming array are processed in pairs with two chars of a pair being converted to a single byte.

Parameters
toConvert:char[]

- the hex encoded String to convert.

Returns:byte[]

the raw byte array.

convertFromHexback to summary
public static byte[] convertFromHex(final String toConvert)

Take the incoming String of hex encoded data and convert to the raw byte values.

The characters in the incoming String are processed in pairs with two chars of a pair being converted to a single byte.

Parameters
toConvert:String

- the hex encoded String to convert.

Returns:byte[]

the raw byte array.

convertToHexBytesback to summary
public static byte[] convertToHexBytes(byte[] toBeConverted)

Take the supplied byte array and convert it to to a byte array of the encoded hex values.

Each byte on the incoming array will be converted to two bytes on the return array.

Parameters
toBeConverted:byte[]

- the bytes to be encoded.

Returns:byte[]

the encoded byte array.

convertToHexStringback to summary
public static String convertToHexString(byte[] toBeConverted)

Take the supplied byte array and convert it to a hex encoded String.

Parameters
toBeConverted:byte[]

- the bytes to be converted.

Returns:String

the hex encoded String.

mainback to summary
public static void main(String[] args)
toByteback to summary
private static byte toByte(final char[] toConvert, final int pos)