android 获取apk md5值
1, 获取 Signature
2. 根据Signature计算md5和sha1信息,获取签名公钥信息
TextView text = null;
StringBuffer sb = new StringBuffer();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
text = (TextView) findViewById(R.id.text);
try {
PackageInfo pi = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES);
Signature signatures = pi.signatures[0];
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(signatures.toByteArray());
byte[] digest = md.digest();
String res = toHexString(digest);
Log.e(TAG,
"apk md5 = "+res);
sb.append("apk md5 = "+res);
Mes