public class Hex extends Object
This class is thread-safe.
| Modifier and Type | Field and Description |
|---|---|
private static char[] |
DIGITS_LOWER
Used to build output as hex.
|
private static char[] |
DIGITS_UPPER
Used to build output as hex.
|
| Constructor and Description |
|---|
Hex() |
| Modifier and Type | Method and Description |
|---|---|
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 char[] |
encodeHex(byte[] data,
int dataOffset,
int dataLen,
boolean toLowerCase)
Converts an array of bytes into an array of characters representing the hexadecimal values of each byte in order.
|
static void |
encodeHex(byte[] data,
int dataOffset,
int dataLen,
boolean toLowerCase,
char[] out,
int outOffset)
Converts an array of bytes into an array of characters representing the hexadecimal values of each byte in order.
|
private static void |
encodeHex(byte[] data,
int dataOffset,
int dataLen,
char[] toDigits,
char[] out,
int outOffset)
Converts an array of bytes into an array of characters representing the hexadecimal values of each byte in order.
|
static char[] |
encodeHex(ByteBuffer data)
Converts a byte buffer into an array of characters representing the hexadecimal values of each byte in order.
|
static char[] |
encodeHex(ByteBuffer data,
boolean toLowerCase)
Converts a byte buffer into an array of characters representing the hexadecimal values of each byte in order.
|
protected static char[] |
encodeHex(ByteBuffer byteBuffer,
char[] toDigits)
Converts a byte buffer 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.
|
static String |
encodeHexString(byte[] data,
boolean toLowerCase)
Converts an array of bytes into a String representing the hexadecimal values of each byte in order.
|
static String |
encodeHexString(ByteBuffer data)
Converts a byte buffer into a String representing the hexadecimal values of each byte in order.
|
static String |
encodeHexString(ByteBuffer data,
boolean toLowerCase)
Converts a byte buffer into a String representing the hexadecimal values of each byte in order.
|
private static byte[] |
toByteArray(ByteBuffer byteBuffer)
Convert the byte buffer to a byte array.
|
private static final char[] DIGITS_LOWER
private static final char[] DIGITS_UPPER
public 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 alphabet (must contain at least 16 chars)public static char[] encodeHex(byte[] data,
int dataOffset,
int dataLen,
boolean toLowerCase)
data - a byte[] to convert to hex charactersdataOffset - the position in data to start encoding fromdataLen - the number of bytes from dataOffset to encodetoLowerCase - true converts to lowercase, false to uppercasepublic static void encodeHex(byte[] data,
int dataOffset,
int dataLen,
boolean toLowerCase,
char[] out,
int outOffset)
data - a byte[] to convert to hex charactersdataOffset - the position in data to start encoding fromdataLen - the number of bytes from dataOffset to encodetoLowerCase - true converts to lowercase, false to uppercaseout - a char[] which will hold the resultant appropriate characters from the alphabet.outOffset - the position within out at which to start writing the encoded characters.private static void encodeHex(byte[] data,
int dataOffset,
int dataLen,
char[] toDigits,
char[] out,
int outOffset)
data - a byte[] to convert to hex charactersdataOffset - the position in data to start encoding fromdataLen - the number of bytes from dataOffset to encodetoDigits - the output alphabet (must contain at least 16 chars)out - a char[] which will hold the resultant appropriate characters from the alphabet.outOffset - the position within out at which to start writing the encoded characters.public static char[] encodeHex(ByteBuffer data)
All bytes identified by Buffer.remaining() will be used; after this method
the value remaining() will be zero.
data - a byte buffer to convert to hex characterspublic static char[] encodeHex(ByteBuffer data, boolean toLowerCase)
All bytes identified by Buffer.remaining() will be used; after this method
the value remaining() will be zero.
data - a byte buffer to convert to hex characterstoLowerCase - true converts to lowercase, false to uppercaseprotected static char[] encodeHex(ByteBuffer byteBuffer, char[] toDigits)
All bytes identified by Buffer.remaining() will be used; after this method
the value remaining() will be zero.
byteBuffer - a byte buffer to convert to hex characterstoDigits - the output alphabet (must be at least 16 characters)public static String encodeHexString(byte[] data)
data - a byte[] to convert to hex characterspublic static String encodeHexString(byte[] data, boolean toLowerCase)
data - a byte[] to convert to hex characterstoLowerCase - true converts to lowercase, false to uppercasepublic static String encodeHexString(ByteBuffer data)
All bytes identified by Buffer.remaining() will be used; after this method
the value remaining() will be zero.
data - a byte buffer to convert to hex characterspublic static String encodeHexString(ByteBuffer data, boolean toLowerCase)
All bytes identified by Buffer.remaining() will be used; after this method
the value remaining() will be zero.
data - a byte buffer to convert to hex characterstoLowerCase - true converts to lowercase, false to uppercaseprivate static byte[] toByteArray(ByteBuffer byteBuffer)
Buffer.remaining() will be used.byteBuffer - the byte bufferCopyright © 2024. All rights reserved.