private static byte[] convertCharSequenceToBytes(CharSequence characters) {

		// assumption: no separators

		if (characters.length() % 2 == 1) {
			throw new IllegalArgumentException("Hex string must be an even number of characters");
		}

		try {
			byte[] bytes = new byte[characters.length() / 2];
			for (int i = 0; i < characters.length(); i += 2) {
				CharSequence bs = characters.subSequence(i, i + 2);
				bytes[i / 2] = (byte) Integer.parseInt(bs.toString(), 16);
			}
			return bytes;
		}
		catch (Exception e) {
			// tried, but failed
		}

		return null;
	}
Parse hexadecimal digits into a byte array.

@param hexString hexadecimal digits
@return numeric value as a byte array, or null if string contains invalid hex characters.
Ghidra/Framework/Generic/src/main/java/ghidra/util/NumericUtilities.java