Android获取应用的签名信息

public void getSingInfo() {
try {
PackageInfo packageInfo = getPackageManager().getPackageInfo(
"wabao.et.master", PackageManager.GET_SIGNATURES);
Signature[] signs = packageInfo.signatures;
Signature sign = signs[0];
parseSignature(sign.toByteArray());
} catch (Exception e) {
e.printStackTrace();
}
}


public void parseSignature(byte[] signature) {
try {
CertificateFactory certFactory = CertificateFactory
.getInstance("X.509");
X509Certificate cert = (X509Certificate) certFactory
.generateCertificate(new ByteArrayInputStream(signature));
String pubKey = cert.getPublicKey().toString();
String signNumber = cert.getSerialNumber().toString();
} catch (CertificateException e) {
e.printStackTrace();
}
}

你可能感兴趣的:(Android获取应用的签名信息)