Java tutorial
//package com.java2s; //License from project: Apache License public class Main { private static final char[] DIGITS_LOWER = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; public static String byteToHexString(byte[] bytes) { return String.valueOf(encodeHex(bytes)); } protected static char[] encodeHex(byte[] data) { int l = data.length; char[] out = new char[l << 1]; int i = 0; for (int j = 0; i < l; ++i) { out[j++] = DIGITS_LOWER[(240 & data[i]) >>> 4]; out[j++] = DIGITS_LOWER[15 & data[i]]; } return out; } }