Tuesday, October 2, 2007

java code hexToByte

    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;
}

Tutos(open source project management tools )

http://demo.tutos.de/php/mytutos.php