private final static char[] hexarr = "0123456789ABCDEF".toCharArray();
public static String bytesToHex(byte[] bytes) {
char[] hexchars = new char[bytes.length * 2];
for ( int j = 0; j < bytes.length; j++ ) {
int v = bytes[j] & 0xFF;
hexchars[j * 2] = hexarr[v >>> 4];
hexchars[j * 2 + 1] = hexarr[v & 0x0F];
}
return new String(hexchars);
}