他的龙根本太大了_动漫美女被吸乳视频漫画_欧美xxxx性疯狂bbbb_天天看天天爽天天摸天天添

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://ssll180.com

存檔