Here you can find the source of hexDecode(String data)
public static byte[] hexDecode(String data)
//package com.java2s; public class Main { public static byte[] hexDecode(String data) { byte[] r = new byte[data.length() / 2]; char[] a = data.toCharArray(); for (int i = 0; i < a.length; i += 2) { char c1 = a[i], c2 = a[i + 1]; int v1 = valueOf(c1); int v2 = valueOf(c2); r[i >> 1] = (byte) ((((v1 & 0xf) << 4) | (v2 & 0xf)) & 0xff); }// www . j a v a2s.c o m return r; } private static int valueOf(char c) { c = Character.toLowerCase(c); if (c >= '0' && c <= '9') { return c - '0'; } else if (c >= 'a' && c <= 'f') { return c - 'a' + 10; } return -1; } }