Android获取应用的签名信息
01public void getSingInfo() {
02
try {
03
PackageInfo packageInfo = getPackageManager().getPackageInfo(
04
"wabao.et.master", PackageManager.GET_SIGNATURES);
05
Signature[] signs = packageInfo.signatures;
06
Signature sign = signs[0];
07
parseSignature(sign.toByteArray());
08
} catch (Exception e) {
09 www.zzzyk.com
e.printStackTrace();
10
}
11
}
12
13
public void parseSignature(byte[] signature) {
14
try {
15
CertificateFactory certFactory = CertificateFactory
16
.getInstance("X.509");
17
X509Certificate cert = (X509Certificate) certFactory
18
.generateCertificate(new ByteArrayInputStream(signature));
19
String pubKey = cert.getPublicKey().toString();
20
String signNumber = cert.getSerialNumber().toString();
21
} catch (CertificateException e) {
22
e.printStackTrace();
23
}
24
}
作者:frank
补充:移动开发 , Android ,