Java tutorial
//package com.java2s; //License from project: Apache License import java.io.FileInputStream; import java.io.IOException; import java.security.MessageDigest; public class Main { public static byte[] createMD5(FileInputStream is) throws IOException { MessageDigest digester = null; try { digester = MessageDigest.getInstance("MD5"); byte[] buffer = new byte[16 * 1024]; // 16k int length = 0; while ((length = is.read(buffer)) > 0) { digester.update(buffer, 0, length); } } catch (Exception e) { e.printStackTrace(); } finally { is.close(); } if (digester != null) { return digester.digest(); } return null; } }