Here you can find the source of bytesToHex(byte[] bytes)
public static String bytesToHex(byte[] bytes)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from w ww . j a v a 2 s.c o m*/ * Helper method to convert a byte array to a hexadecimal string. */ public static String bytesToHex(byte[] bytes) { StringBuilder sb = new StringBuilder(); for (byte hashByte : bytes) { int intVal = 0xff & hashByte; if (intVal < 0x10) { sb.append('0'); } sb.append(Integer.toHexString(intVal)); } return sb.toString(); } }