Java tutorial
//package com.java2s; // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of import java.math.BigInteger; public class Main { private static String toHex(byte[] bytes) { BigInteger bi = new BigInteger(1, bytes); return String.format("%0" + (bytes.length << 1) + "X", bi); } }