Java tutorial
//package com.java2s; //License from project: Apache License public class Main { private static final char hex[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; public static String toHexString(byte[] bytes) { StringBuilder sb = new StringBuilder(bytes.length * 2); for (byte b : bytes) { sb.append(hex[((b >> 4) & 0xF)]).append(hex[((b >> 0) & 0xF)]); } return sb.toString(); } }