Expresso 5-6

com.jcorporate.expresso.core.misc
Class HexEncoder

java.lang.Object
  extended bycom.jcorporate.expresso.core.misc.HexEncoder

public class HexEncoder
extends Object

Hex encoding class. Many thanks goes to Wei Dai's Crypto++ for providing public domain C++ code that this could be derived from.

Author:
Michael Rimov

Constructor Summary
HexEncoder()
           
 
Method Summary
static byte[] decode(String inputData)
          Decodes a string containing hexadecimal characters into the resulting binary values.
static String encode(byte[] inputData)
          Encode an array of binary data into a string of hexadecimal values.
static String encode(String s)
          Encode an array of binary data into a string of hexadecimal values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HexEncoder

public HexEncoder()
Method Detail

decode

public static byte[] decode(String inputData)
                     throws IllegalArgumentException
Decodes a string containing hexadecimal characters into the resulting binary values.

Parameters:
inputData - - The string to be decoded. The input string must have only characters "0-9 and A-F" Any other characters in the string will result in an illegal argument exception.
Returns:
an array of bytes representing the decoded input string
Throws:
IllegalArgumentException - if the string is null, is of zero length, or contains illegal characters.

encode

public static String encode(byte[] inputData)
                     throws IllegalArgumentException
Encode an array of binary data into a string of hexadecimal values.

Parameters:
inputData - - A byte array that will be encoded.
Returns:
The resulting encoded string.
Throws:
IllegalArgumentException - If the length of the byte array is zero.

encode

public static String encode(String s)
                     throws IllegalArgumentException
Encode an array of binary data into a string of hexadecimal values.

Parameters:
s - the string to encode
Returns:
The resulting encoded string.
Throws:
IllegalArgumentException - If the length of the byte array is zero.

Expresso 5-6

Please see www.jcorporate.com for information about new Expresso releases.