static byte[] hex2Bytes(String s) {
        if ((s.length() & 1) != 0) {
            throw new IllegalArgumentException("String length must be even: " + s.length());
        }

        byte[] buf = new byte[s.length() / 2];

        for (int index = 0; index < buf.length; index++) {
            final int stringIndex = index << 1;
            buf[index] = (byte) Integer.parseInt(s.substring(stringIndex, stringIndex + 2), 16);
        }
        return buf;
    }