国产成在线人视频免费视频-国产成综合-国产床上视频-国产大臿蕉香蕉大视频女-国产大尺度pr社18福利在线

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.z1277.cn

存檔

主站蜘蛛池模板: 立即播放免费毛片一级 | jizz国产精品 | 国产伦精品一区二区三区视频小说 | 欧美色欧美亚洲高清在线观看 | 美国一级大黄大黄大色毛片a | 午夜激情视频在线 | 在线观看国产精品一区 | 久久国产乱子伦精品岳两 | 尤物视频在线看 | 看成年全黄大色黄大片 | 成人午夜亚洲影视在线观看 | 日韩美女黄大片在线观看 | 亚洲岛国片 | 97超级碰久久久久香蕉人人 | 香港毛片免费观看 | 国产福利91| 欧美日韩一区二区三区自拍 | 国产免费福利视频一区二区 | 色综合天天综合网国产成人网 | 污污网站免费入口链接 | 看全色黄大色黄女片爽老外 | 97精品视频在线观看 | 国产精品原创巨作无遮挡 | 一区二区三区在线免费观看视频 | 日韩视频一区二区 | 特级毛片免费视频播放 | 大香萑75久久精品免费 | 高清中文字幕视频在线播 | 麻豆视频免费观看入口 | 国产一区二区精品人妖系列 | 免费观看亚洲 | 高潮影院| 亚洲精选| 亚瑟福利视频在线观看 | 亚洲国产片高清在线观看 | 欧美日韩亚洲无线码在线观看 | 国产高清免费午夜在线视频 | 美女黄视频大全 | 在浴室边摸边吃奶边做视频 | 九九操视频 | 欧美视屏在线观看 |