当前位置:操作系统 > 安卓/Android >>

Android获取应用的签名信息

01
public 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 ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,