Here you can find the source of bytesToHex(byte[] digest)
public static String bytesToHex(byte[] digest)
//package com.java2s; //License from project: Apache License public class Main { public final static String EMPTY = ""; public static String bytesToHex(byte[] digest) { StringBuffer buffer = new StringBuffer(""); for (int i = 0; i < digest.length; i++) { String hexValue = Integer.toHexString(digest[i] & 0xFF); if (hexValue.length() == 1) { buffer.append(0);/*from w w w. j a va 2 s. c o m*/ } buffer.append(hexValue); } return buffer.toString(); } public static String toString(Object obj) { if (obj == null) { return EMPTY; } else { return String.valueOf(obj); } } }