public static byte[] hexStringToByteArray(String input){
  if ((input == null) || (input.length() % 2 != 0)) {
    throw new IllegalArgumentException("The input must not be null and " + "shall have an even number of hexadecimal characters. Found: " + input);
  }
  byte[] output=new byte[input.length() / 2];
  for (int i=0; i < output.length; i++) {
    output[i]=(byte)((Character.digit(input.charAt(i * 2),16) << 4) + Character.digit(input.charAt(i * 2 + 1),16));
  }
  return output;
}

public static byte [ ] hexStringToByteArray ( String input ) { if ( ( input == null ) || ( input . length ( ) % 2 != 0 ) ) { throw new IllegalArgumentException ( "The input must not be null and " + "shall have an even number of hexadecimal characters. Found: " + input ) ; } byte [ ] output = new byte [ input . length ( ) / 2 ] ; for ( int i = 0 ; i < output . length ; i ++ ) { output [ i ] = ( byte ) ( ( Character . digit ( input . charAt ( i * 2 ) , 16 ) << 4 ) + Character . digit ( input . charAt ( i * 2 + 1 ) , 16 ) ) ; } return output ; }
converts a string with an even number of hexadecimal characters to a byte array .
