private static final int stream_buffer_length = 1024;
private static final String algorithm_md5 = "MD5";
public static String md5file (file file) {if (null = = File) {return ""; } String result = ""; try {messagedigest digest = messagedigest.getinstance (ALGORITHM_MD5); Byte[] digests = Updatedigest (Digest, new FileInputStream (file)). Digest (); BigInteger bi = new BigInteger (1, digests); result = Bi.tostring (16); } catch (NoSuchAlgorithmException e) {e.printstacktrace (); } catch (FileNotFoundException e) {e.printstacktrace (); } catch (IOException e) {e.printstacktrace (); } return result; } public static MessageDigest Updatedigest (Final MessageDigest Digest, final InputStream data) throws IOException { Final byte[] buffer = new Byte[stream_buffer_length]; int read = data.read (buffer, 0, stream_buffer_length); while (Read >-1) {digest.update (buffer, 0, read); Read = data.read (buffer, 0,Stream_buffer_length); } return digest; }
Android uses MD5 encrypted files