Here you can find the source of ByteToHex(byte[] bytes)
public static String ByteToHex(byte[] bytes)
//package com.java2s; //License from project: Apache License public class Main { public static String ByteToHex(byte[] bytes) { StringBuffer sha1StrBuff = new StringBuffer(); for (int i = 0; i < bytes.length; ++i) { if (Integer.toHexString(255 & bytes[i]).length() == 1) { sha1StrBuff.append("0").append(Integer.toHexString(255 & bytes[i])); } else { sha1StrBuff.append(Integer.toHexString(255 & bytes[i])); }//from w w w . j a va 2s.co m } return sha1StrBuff.toString(); } }