public static byte[] hexStringToBytes(String hexString){
  if (hexString == null || hexString.equals("")) {
    return null;
  }
  hexString=hexString.toUpperCase();
  int length=hexString.length() / 2;
  char[] hexChars=hexString.toCharArray();
  byte[] d=new byte[length];
  for (int i=0; i < length; i++) {
    int pos=i * 2;
    d[i]=(byte)(charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1]));
  }
  return d;
}

public static byte [ ] hexStringToBytes ( String hexString ) { if ( hexString == null || hexString . equals ( "" ) ) { return null ; } hexString = hexString . toUpperCase ( ) ; int length = hexString . length ( ) / 2 ; char [ ] hexChars = hexString . toCharArray ( ) ; byte [ ] d = new byte [ length ] ; for ( int i = 0 ; i < length ; i ++ ) { int pos = i * 2 ; d [ i ] = ( byte ) ( charToByte ( hexChars [ pos ] ) << 4 | charToByte ( hexChars [ pos + 1 ] ) ) ; } return d ; }
convert hex string to byte [ ]
