|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.shiro.codec.Hex
public class Hex
Hexadecimal encoder and decoder.
This class was borrowed from Apache Commons Codec SVN repository (rev.560660
) with modifications
to enable Hex conversion without a full dependency on Commons Codec. We didn't want to reinvent the wheel of
great work they've done, but also didn't want to force every Shiro user to depend on the commons-codec.jar
As per the Apache 2.0 license, the original copyright notice and all author and copyright information have
remained in tact.
Constructor Summary | |
---|---|
Hex()
|
Method Summary | |
---|---|
static byte[] |
decode(byte[] array)
Converts an array of character bytes representing hexidecimal values into an array of bytes of those same values. |
static byte[] |
decode(char[] data)
Converts an array of characters representing hexidecimal values into an array of bytes of those same values. |
static byte[] |
decode(String hex)
Converts the specified Hex-encoded String into a raw byte array. |
static char[] |
encode(byte[] data)
Converts an array of bytes into an array of characters representing the hexidecimal values of each byte in order. |
static String |
encodeToString(byte[] bytes)
Encodes the specifed byte array to a character array and then returns that character array as a String. |
protected static int |
toDigit(char ch,
int index)
Converts a hexadecimal character to an integer. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Hex()
Method Detail |
---|
public static String encodeToString(byte[] bytes)
bytes
- the byte array to Hex-encode.
public static char[] encode(byte[] data)
data
- byte[] to convert to Hex characters
public static byte[] decode(byte[] array) throws IllegalArgumentException
array
- An array of character bytes containing hexidecimal digits
IllegalArgumentException
- Thrown if an odd number of characters is supplied
to this functiondecode(char[])
public static byte[] decode(String hex)
decode(char[])
using the
argument's hex.toCharArray() value.
hex
- a Hex-encoded String.
public static byte[] decode(char[] data) throws IllegalArgumentException
data
- An array of characters containing hexidecimal digits
IllegalArgumentException
- if an odd number or illegal of characters
is suppliedprotected static int toDigit(char ch, int index) throws IllegalArgumentException
ch
- A character to convert to an integer digitindex
- The index of the character in the source
IllegalArgumentException
- if ch is an illegal hex character
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |