public static String encode(/*const*/ byte[] data, int off, int len)
{
char[] ch;
int i;
// Convert bytes to hex digits
ch = new char[data.length*2];
i = 0;
while (len-- > 0)
{
int b;
int d;
// Convert next byte into a hex digit pair
b = data[off++] & 0xFF;
d = b >> 4;
d = (d < 0xA ? d+'0' : d-0xA+'A');
ch[i++] = (char) d;
d = b & 0xF;
d = (d < 0xA ? d+'0' : d-0xA+'A');
ch[i++] = (char) d;
}
return (new String(ch));
}