code: public static byte[] hexToBytes(String hex) {
  		int length = hex.length();
  		byte[] ret = new byte[length / 2];
  		for (int i = 0; i < length; i += 2) {
  			ret[i / 2] = (byte) ((Character.digit(hex.charAt(i), 16) << 4) + Character.digit(hex.charAt(i + 1), 16));
  		}
  		return ret;
  	}
docs: Converts a hex String to a byte array.