Here you can find the source of MD5Sum(byte[] par1Data)
public static String MD5Sum(byte[] par1Data)
//package com.java2s; //License from project: Open Source License import java.io.FileInputStream; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static String MD5Sum(byte[] par1Data) { try {/*from w ww . ja va 2s. co m*/ MessageDigest md5 = MessageDigest.getInstance("MD5"); StringBuilder sb = new StringBuilder(); for (byte t : md5.digest(par1Data)) { sb.append(Integer.toHexString(t & 0xFF)); } return sb.toString(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } return ""; } public static String MD5Sum(String par1Data) { return MD5Sum(par1Data.getBytes()); } public static String MD5Sum(FileInputStream par1Stream) { FileChannel ic = null; ByteBuffer bb = null; try { ic = par1Stream.getChannel(); bb = ByteBuffer.allocate((int) ic.size()); ic.read(bb); } catch (IOException e) { throw new RuntimeException(e); } finally { try { if (ic != null) ic.close(); } catch (IOException e) { throw new RuntimeException(e); } } return MD5Sum(bb.array()); } }