Package org.forgerock.util.encode
Class Hex
java.lang.Object
org.forgerock.util.encode.Hex
Routines for encoding and decoding binary data in hexadecimal format.
- 
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]Decodes a hexadecimal-encoded string into an equivalent byte array, treating each two-character sequence as a single byte in big-endian order.static byte[]decodeStrict(String hex) Decodes a hexadecimal-encoded string into an equivalent byte array, treating each two-character sequence as a single byte in big-endian order.static Stringencode(byte[] data) Encodes binary data into hexadecimal format.static StringencodeLowerCase(byte[] data) Encodes binary data into hexadecimal format using lowercase characters for 'a' to 'f'.static StringencodeUpperCase(byte[] data) Encodes binary data into hexadecimal format using uppercase characters for 'A' to 'F'. 
- 
Method Details
- 
decode
Decodes a hexadecimal-encoded string into an equivalent byte array, treating each two-character sequence as a single byte in big-endian order. The input can use either uppercase or lowercase characters, or a combination of both. Any invalid characters in the input will be skipped. UsedecodeStrict(String)if you want stricter decoding.- Parameters:
 hex- the input value in hexadecimal format.- Returns:
 - the equivalent output bytes.
 - Throws:
 NullPointerException- if the input is null.IllegalArgumentException- if the input length, after stripping invalid characters, is not divisible by 2.
 - 
decodeStrict
Decodes a hexadecimal-encoded string into an equivalent byte array, treating each two-character sequence as a single byte in big-endian order. The input can use either uppercase or lowercase characters, or a combination of both. Any invalid characters in the input will result in anIllegalArgumentException.- Parameters:
 hex- the input value in hexadecimal format.- Returns:
 - the equivalent output bytes.
 - Throws:
 NullPointerException- if the input is null.IllegalArgumentException- if any non-hex characters occur in the input or the length is not divisible by two.
 - 
encodeUpperCase
Encodes binary data into hexadecimal format using uppercase characters for 'A' to 'F'.- Parameters:
 data- the data to encode.- Returns:
 - the hexadecimal-encoded data.
 - Throws:
 NullPointerException- if the input data is null.
 - 
encodeLowerCase
Encodes binary data into hexadecimal format using lowercase characters for 'a' to 'f'.- Parameters:
 data- the data to encode.- Returns:
 - the hexadecimal-encoded data.
 - Throws:
 NullPointerException- if the input data is null.
 - 
encode
Encodes binary data into hexadecimal format. This method is equivalent toencodeLowerCase(byte[]).- Parameters:
 data- the data to encode.- Returns:
 - the hexadecimal-encoded data.
 - Throws:
 NullPointerException- if the input data is null.
 
 -