이 응용 프로그램 APK 파일 md5 가 져 오기

1357 단어 androidapkmd5
MD5 소개
http://baike.baidu.com/link?url=WicTvWv2haI7QrJdoPK0asQbQEujnJ9-iU6G_N2L2H4fwK6hsdkE6Rw1H9Gi_iVHiVhK4SzUfoZcYvzQ3lInSK
방법 실현
/**
*      md5 
* @param path         
* @return    md5 
*/

public static String getFileMd5(String path){

    try {
        //            ,    。
        File file = new File(path);
        // md5
        MessageDigest digest = MessageDigest.getInstance("md5");
        FileInputStream fis = new FileInputStream(file);
        byte[] buffer = new byte[1024];
        int len = -1;
        while ((len = fis.read(buffer)) != -1) {
            digest.update(buffer, 0, len);
        }
        byte[] result = digest.digest();
        StringBuffer sb  = new StringBuffer();
        for (byte b : result) {
            //    
            int number = b & 0xff;//   
            String str = Integer.toHexString(number);
            // System.out.println(str);
            if (str.length() == 1) {
                sb.append("0");
            }
            sb.append(str);
        }
        return sb.toString();
    } catch (Exception e) {
        e.printStackTrace();
        return "";
    }
}

apk 파일 이 있 는 디 렉 터 리
//         apk   data/app   
//       apk   system/app   
String path=getApplicationContext().getPackageResourcePath();  

좋은 웹페이지 즐겨찾기