Here you can find the source of toHex(byte[] src)
public static byte[] toHex(byte[] src)
//package com.java2s; //License from project: Open Source License public class Main { private final static byte[] CHEX = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; public static byte[] toHex(byte[] src) { int l = src.length; byte dst[] = new byte[l * 2]; for (int i = 0, j = 0; i < l; i++) { int k = src[i]; k &= (int) 0xFF; dst[j++] = CHEX[k >> 4]; dst[j++] = CHEX[k & 0x0F]; }//from w ww. ja va 2 s . co m return dst; } }