Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> Android獲取應用的簽名信息

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.2cto.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
  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved