Here you can find the source of md5(byte[] buf)
public static String md5(byte[] buf)
//package com.java2s; //License from project: Apache License import java.security.MessageDigest; public class Main { public static String md5(byte[] buf) { String result = ""; try {/*from ww w.j a v a 2 s . co m*/ MessageDigest md = MessageDigest.getInstance("MD5"); md.update(buf); result = toHex(md.digest()); } catch (Exception e) { e.printStackTrace(); } return result; } private static String toHex(byte[] digest) { StringBuffer buffer = new StringBuffer(); for (int i = 0; i < digest.length; ++i) { byte b = digest[i]; int value = (b & 0x7F) + (b < 0 ? 128 : 0); buffer.append(value < 16 ? "0" : ""); buffer.append(Integer.toHexString(value)); } return buffer.toString(); } }