]> matita.cs.unibo.it Git - logicplayer.git/blobdiff - mainActivity/src/com/example/furt/myapplication/MD5.java
Ported to latest version of Android SDK
[logicplayer.git] / mainActivity / src / com / example / furt / myapplication / MD5.java
diff --git a/mainActivity/src/com/example/furt/myapplication/MD5.java b/mainActivity/src/com/example/furt/myapplication/MD5.java
deleted file mode 100755 (executable)
index dc28986..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-package com.example.furt.myapplication;
-
-import android.os.Environment;
-
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.security.MessageDigest;
-
-
-public class MD5 {
-
-    MD5(){}
-
-    public static String digest(String filePath) {
-        InputStream inputStream = null;
-        try {
-            inputStream = new FileInputStream(Environment.getExternalStorageDirectory()+"/tesiEs/"+filePath);
-            byte[] buffer = new byte[1024];
-            MessageDigest digest = MessageDigest.getInstance("MD5");
-            int numRead = 0;
-            while (numRead != -1) {
-                numRead = inputStream.read(buffer);
-                if (numRead > 0)
-                    digest.update(buffer, 0, numRead);
-            }
-            byte [] md5Bytes = digest.digest();
-            return convertHashToString(md5Bytes);
-        } catch (Exception e) {
-            return null;
-        } finally {
-            if (inputStream != null) {
-                try {
-                    inputStream.close();
-                } catch (Exception e) { }
-            }
-        }
-    }
-
-    private static String convertHashToString(byte[] md5Bytes) {
-        String returnVal = "";
-        for (int i = 0; i < md5Bytes.length; i++) {
-            returnVal += Integer.toString(( md5Bytes[i] & 0xff ) + 0x100, 16).substring(1);
-        }
-        return returnVal;
-    }
-}