public class HexHelper extends Object
Modifier and Type | Method | Description |
---|---|---|
static byte[] |
fromHex(char separator,
String value) |
Decodes a hexidecimal string (optionally with
separator characters separating each two-digit pair)Multiple runs of the separator will be ignored (eg. |
static byte[] |
fromHex(String value) |
Decodes a hexidecimal string into a series of bytes
|
static byte[] |
generateBytes(int bytes) |
Generates a number of random bytes which can then be manipulated and/or converted to hex
Uses a new instance of java.util.Random |
static byte[] |
generateBytes(Random rand,
int bytes) |
Generates a number of random bytes which can then be manipulated and/or converted to hex
|
static String |
generateHex(int characters) |
Generates a hexidecimal String of length
characters |
static String |
generateHex(Random random,
int characters) |
Generates a hexidecimal String of length
characters |
static String |
toHex(byte... bin) |
Encodes a series of bytes into a hexidecimal string (potentially with leading zeroes) with no separators between each
source byte
|
static String |
toHex(char separator,
byte... bin) |
Encodes a series of bytes into a hexidecimal string with each source byte (represented in the output as a 2 digit
hexidecimal pair) separated by
separator |
public static final byte[] fromHex(String value)
value
- public static final byte[] fromHex(char separator, String value)
separator
characters separating each two-digit pair)[0xAA,0xBB]
, not
[0xAA,0x00,0xBB]
)separator
- the separator charactervalue
- public static final byte[] generateBytes(int bytes)
bytes
- public static final byte[] generateBytes(Random rand, int bytes)
RANDOM
- the random number generator to usebytes
- public static final String generateHex(int characters)
characters
characters
- the number of characters in the resulting Stringpublic static final String generateHex(Random random, int characters)
characters
random
- the random number generator to usecharacters
- the number of characters in the resulting Stringpublic static final String toHex(byte... bin)
bin
- public static final String toHex(char separator, byte... bin)
separator
separator
- The character to insert between each byte (for example, ':'
)bin
- the series of bytes to encodeseparator
Copyright © 2018. All rights reserved.