Here you can find the source of bytesToHexString(byte[] bArray)
public static final String bytesToHexString(byte[] bArray)
//package com.java2s; //License from project: Apache License public class Main { private static final char[] ac = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; public static final String bytesToHexString(byte[] bArray) { StringBuffer sb = new StringBuffer(bArray.length); for (int i = 0; i < bArray.length; i++) { String sTemp = byteToHexString(bArray[i]); sb.append(sTemp.toUpperCase()); }//from www . jav a2 s .com return sb.toString(); } private static String byteToHexString(byte b) { char[] ch = new char[2]; ch[0] = ac[(b >>> 4 & 0xF)]; ch[1] = ac[(b & 0xF)]; String s = new String(ch); return new String(ch); } }