private static final String HEXINDEX = "0123456789abcdef ABCDEF";
public static byte[] hexToByte(String s) {
int l = s.length() / 2;
byte data[] = new byte[l];
int j = 0;
for (int i = 0; i < l; i++) {
char c = s.charAt(j++);
int n, b;
n = HEXINDEX.indexOf(c);
b = (n & 0xf) << 4;
c = s.charAt(j++);
n = HEXINDEX.indexOf(c);
b += (n & 0xf);
data[i] = (byte) b;
}
return data;
}
Tuesday, October 2, 2007
java code hexToByte
Subscribe to:
Posts (Atom)