code: public static byte[] hex2bin(final String s)
      {
          String m = s;
          if (s == null)
          {
              // Allow empty input string.
              m = "";
          }
          else if (s.length() % 2 != 0)
          {
              // Assume leading zero for odd string length
              m = "0" + s;
          }
          byte r[] = new byte[m.length() / 2];
          for (int i = 0, n = 0; i < m.length(); n++)
          {
              char h = m.charAt(i++);
              char l = m.charAt(i++);
              r[n] = (byte) (hex2bin(h) * 16 + hex2bin(l));
          }
          return r;
      }
docs: Convert hex string to array of bytes.
  
  @param s
  String containing hexadecimal digits. May be <code>null</code>.
  On odd length leading zero will be assumed.
  @return Array on bytes, non-<code>null</code>.
  @throws IllegalArgumentException
  when string contains non-hex character