Here you can find the source of toHex(byte hash[])
private static final String toHex(byte hash[])
//package com.java2s; public class Main { private static final String toHex(byte hash[]) { if (hash == null) { return null; }/* www . jav a 2s. co m*/ StringBuffer buf = new StringBuffer(hash.length * 2); int i; for (i = 0; i < hash.length; i++) { if ((hash[i] & 0xff) < 0x10) { buf.append("0"); } buf.append(Long.toString(hash[i] & 0xff, 16)); } return buf.toString(); } }