1 package com.example.furt.myapplication;
3 import android.os.Environment;
5 import java.io.FileInputStream;
6 import java.io.InputStream;
7 import java.security.MessageDigest;
14 public static String digest(String filePath) {
15 InputStream inputStream = null;
17 inputStream = new FileInputStream(Environment.getExternalStorageDirectory()+"/tesiEs/"+filePath);
18 byte[] buffer = new byte[1024];
19 MessageDigest digest = MessageDigest.getInstance("MD5");
21 while (numRead != -1) {
22 numRead = inputStream.read(buffer);
24 digest.update(buffer, 0, numRead);
26 byte [] md5Bytes = digest.digest();
27 return convertHashToString(md5Bytes);
28 } catch (Exception e) {
31 if (inputStream != null) {
34 } catch (Exception e) { }
39 private static String convertHashToString(byte[] md5Bytes) {
40 String returnVal = "";
41 for (int i = 0; i < md5Bytes.length; i++) {
42 returnVal += Integer.toString(( md5Bytes[i] & 0xff ) + 0x100, 16).substring(1);