<em id="09ttv"></em>
    <sup id="09ttv"><pre id="09ttv"></pre></sup>
    <dd id="09ttv"></dd>

        • Android 獲取應用 MD5 SHA1 SHA256 簽名信息

          2020-2-8    seo達人

          閑著沒事兒寫了個小 demo ,獲取手機上已安裝應用信息,系統應用和 非系統應用

          MD5 SHA1 SHA256 簽名信息 點擊簽名信息可復制到剪切板,

          GitHub:https://github.com/sunan-n/GetAppInfo

          如下圖:






          
          <span style="white-space:pre;"> </span>主要就是這個方法,傳參數進來獲取相應的簽名類型 信息<br />
          &nbsp; &nbsp; public static String getSignaturesInfo(Context context, String packageName, String tpye) {<br />
          //&nbsp; &nbsp; &nbsp; &nbsp; //獲取包管理器<br />
          &nbsp; &nbsp; &nbsp; &nbsp; PackageManager pm = context.getPackageManager();<br />
          &nbsp; &nbsp; &nbsp; &nbsp; //返回包括在包中的簽名信息<br />
          &nbsp; &nbsp; &nbsp; &nbsp; int flags = PackageManager.GET_SIGNATURES;<br />
          &nbsp; &nbsp; &nbsp; &nbsp; PackageInfo packageInfo = null;<br />
          &nbsp; &nbsp; &nbsp; &nbsp; try {<br />
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //獲得包的所有內容信息類<br />
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; packageInfo = pm.getPackageInfo(packageName, flags);<br />
          &nbsp; &nbsp; &nbsp; &nbsp; } catch (PackageManager.NameNotFoundException e) {<br />
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.printStackTrace();<br />
          &nbsp; &nbsp; &nbsp; &nbsp; }<br />
          &nbsp; &nbsp; &nbsp; &nbsp; //簽名信息<br />
          &nbsp; &nbsp; &nbsp; &nbsp; Signature[] signatures = packageInfo.signatures;<br />
          &nbsp; &nbsp; &nbsp; &nbsp; byte[] cert = signatures[0].toByteArray();<br />
          &nbsp; &nbsp; &nbsp; &nbsp; //將簽名轉換為字節數組流<br />
          &nbsp; &nbsp; &nbsp; &nbsp; InputStream input = new ByteArrayInputStream(cert);<br />
          &nbsp; &nbsp; &nbsp; &nbsp; //證書工廠類,這個類實現了出廠合格證算法的功能<br />
          &nbsp; &nbsp; &nbsp; &nbsp; CertificateFactory cf = null;<br />
          &nbsp; &nbsp; &nbsp; &nbsp; try {<br />
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cf = CertificateFactory.getInstance("X509");<br />
          &nbsp; &nbsp; &nbsp; &nbsp; } catch (CertificateException e) {<br />
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.printStackTrace();<br />
          &nbsp; &nbsp; &nbsp; &nbsp; }<br />
          &nbsp; &nbsp; &nbsp; &nbsp; //X509證書,X.509是一種非常通用的證書格式<br />
          &nbsp; &nbsp; &nbsp; &nbsp; X509Certificate c = null;<br />
          &nbsp; &nbsp; &nbsp; &nbsp; try {<br />
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; c = (X509Certificate) cf.generateCertificate(input);<br />
          &nbsp; &nbsp; &nbsp; &nbsp; } catch (CertificateException e) {<br />
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.printStackTrace();<br />
          &nbsp; &nbsp; &nbsp; &nbsp; }<br />
          &nbsp; &nbsp; &nbsp; &nbsp; String hexString = null;<br />
          &nbsp; &nbsp; &nbsp; &nbsp; try {<br />
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //加密算法的類,這里的參數可以使MD4,MD5等加密算法<br />
          //&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MessageDigest md = MessageDigest.getInstance("SHA1");<br />
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MessageDigest md = MessageDigest.getInstance(tpye);<br />
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //獲得公鑰<br />
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; byte[] publicKey = md.digest(c.getEncoded());<br />
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //字節到十六進制的格式轉換<br />
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hexString = byte2HexFormatted(publicKey);<br />
          &nbsp; &nbsp; &nbsp; &nbsp; } catch (NoSuchAlgorithmException e1) {<br />
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e1.printStackTrace();<br />
          &nbsp; &nbsp; &nbsp; &nbsp; } catch (CertificateEncodingException e) {<br />
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.printStackTrace();<br />
          &nbsp; &nbsp; &nbsp; &nbsp; }<br />
          &nbsp; &nbsp; &nbsp; &nbsp; return hexString;<br />
          &nbsp; &nbsp; }<br />
          <br />

          日歷

          鏈接

          個人資料

          藍藍設計的小編 http://www.sdgs6788.com

          存檔

          色综合久久无码中文字幕| 99久久精品免费看国产一区二区三区| 久久亚洲熟女cc98cm| 亚洲精品高清国产一线久久| 国产综合久久久久久鬼色| 国产精品热久久毛片| 久久久久久久综合狠狠综合| 亚洲国产精品无码久久一线 | 久久精品国产亚洲AV影院| 九九久久自然熟的香蕉图片| 久久婷婷五月综合色99啪ak| 久久香综合精品久久伊人| 日本精品久久久久久久久免费| 精品久久久久久亚洲| 久久久国产乱子伦精品作者| 亚洲成色WWW久久网站| 久久受www免费人成_看片中文 | 亚洲精品国产字幕久久不卡| 色婷婷综合久久久久中文字幕| 日本精品久久久久中文字幕| 久久久久久狠狠丁香| 99热成人精品免费久久| 久久精品无码免费不卡| 综合久久久久久中文字幕亚洲国产国产综合一区首 | 久久国产成人午夜AV影院| 久久久久久亚洲精品不卡| 天天综合久久一二三区| 日韩精品久久久肉伦网站| 国产99久久久久久免费看| 久久这里只有精品视频99| 噜噜噜色噜噜噜久久| 狠狠色婷婷久久一区二区| 91视频国产91久久久| 久久婷婷色综合一区二区| 午夜天堂av天堂久久久| 久久精品国产只有精品66| 人妻无码中文久久久久专区| 久久伊人亚洲AV无码网站| 狠狠88综合久久久久综合网| 一级做a爰片久久毛片毛片| 久久99国产精品成人欧美|