Here you can find the source of MD5(byte[] src)
public static String MD5(byte[] src)
//package com.java2s; //License from project: Open Source License import java.io.*; import java.security.*; public class Main { private static final ThreadLocal<MessageDigest> md5 = new ThreadLocal<MessageDigest>() { @Override/*w ww .j a v a 2 s .c o m*/ protected MessageDigest initialValue() { MessageDigest crypt = null; try { crypt = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } return crypt; } }; public static String MD5(byte[] src) { try { MessageDigest crypt = MessageDigest.getInstance("MD5"); crypt.reset(); crypt.update(src); return ToHex(crypt.digest()); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } return null; } public static String MD5(RandomAccessFile randomAccessFile) { try { MessageDigest crypt = md5.get(); crypt.reset(); byte[] block = new byte[8 * 1024]; for (int i = 0; i < randomAccessFile.length(); i += 8 * 1024) { int len = (int) Math.min(block.length, randomAccessFile.length() - i); randomAccessFile.readFully(block, 0, len); crypt.update(block, 0, len); } return ToHex(crypt.digest()); } catch (IOException e) { e.printStackTrace(); } return null; } public static String ToHex(byte[] src) { String res = ""; for (int i = 0; i < src.length; i++) { res += String.format("%02X", src[i] & 0xFF); } return res.toLowerCase(); } }