org.apache.commons.codec.binary
Class Hex

java.lang.Object
  |
  +--org.apache.commons.codec.binary.Hex

public class Hex
extends java.lang.Object

Hex encoder/decoder

Author:
Christopher O'Brien, Tim O'Brien

Constructor Summary
Hex()
           
 
Method Summary
static byte[] decodeHex(char[] data)
          Converts an array of characters representing hexidecimal values into an array of bytes of those same values.
static char[] encodeHex(byte[] data)
          Converts an array of bytes into an array of characters representing the hexidecimal values of each byte in order.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Hex

public Hex()
Method Detail

encodeHex

public static char[] encodeHex(byte[] data)
Converts an array of bytes into an array of characters representing the hexidecimal values of each byte in order. The returned array will be double the length of the passed array, as it takes two characters to represent any given byte.


decodeHex

public static byte[] decodeHex(char[] data)
                        throws java.lang.Exception
Converts an array of characters representing hexidecimal values into an array of bytes of those same values. The returned array will be half the length of the passed array, as it takes two characters to represent any given byte. An exception is thrown if the passed char array has an odd number of elements.

java.lang.Exception


Copyright © 2002-2003 Apache Software Foundation. All Rights Reserved.