public static byte[] hex2bytes( String hex ) 
	throws NumberFormatException {

	if( hex == null )
	    return null;

	if( hex.length()%2 != 0 )
	    throw new NumberFormatException( "Cannot convert hex strings with odd numbers of characters to byte arrays." );

	byte[] arr = new byte[ hex.length() / 2 ];

	int hi, lo;
	char c_hi, c_lo;
	for( int i = 0; i < arr.length; i++ ) {

	    c_hi = hex.charAt( i*2 );
	    c_lo = hex.charAt( i*2 + 1);
	    
	    hi = hex2int( c_hi );
	    lo = hex2int( c_lo );
	    //System.out.println( "hi=" + c_hi + "(" + hi + "), lo=" +  c_lo + "(" + lo + ")" );

	    arr[i] = (byte)((hi << 4) | lo);

	    
	}

	return arr;
    }