美文网首页
获取应用签名

获取应用签名

作者: 小慕汐 | 来源:发表于2016-10-21 18:31 被阅读34次
    public void getSingInfo(PackageInfo packageInfo) {
       try {
          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();
       }
    }

相关文章

网友评论

      本文标题:获取应用签名

      本文链接:https://www.haomeiwen.com/subject/wgjcuttx.html