当前位置:网站首页>App SHA1 acquisition program Baidu map Gaode map simple program for acquiring SHA1 value
App SHA1 acquisition program Baidu map Gaode map simple program for acquiring SHA1 value
2022-06-23 05:52:00 【Muzi 102】
When integrating maps in a project, you often need to go to SHA1 This value is used to configure key The following is a simple acquisition app SHA1 Value program
/** * obtain sha1 * @param context * @return */
public String sHA1(Context context) {
try {
PackageInfo info = context.getPackageManager().getPackageInfo(
context.getPackageName(), PackageManager.GET_SIGNATURES);
byte[] cert = info.signatures[0].toByteArray();
MessageDigest md = MessageDigest.getInstance("SHA1");
byte[] publicKey = md.digest(cert);
StringBuffer hexString = new StringBuffer();
for (int i = 0; i < publicKey.length; i++) {
String appendString = Integer.toHexString(0xFF & publicKey[i])
.toUpperCase(Locale.US);
if (appendString.length() == 1)
hexString.append("0");
hexString.append(appendString);
hexString.append(":");
}
String result = hexString.toString();
return result.substring(0, result.length() - 1);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
return null;
}边栏推荐
猜你喜欢

数字藏品市场才刚刚开始

jvm-05.垃圾回收

ArcTime 制作中英文字幕视频

Jvm: when a method is overloaded, the specific method to call is determined by the static type of the incoming parameter rather than the actual type of the parameter

Management system of borrowed books based on SSM framework

Arctime makes Chinese and English subtitle video

Activity启动模式和生命周期实测结果

Skill self check | do you know these 6 skills if you want to be a test leader?

Kotlin android简单Activity跳转、handler和thread简单配合使用

Software design and Development Notes 2: serial port debugging tool based on QT design
随机推荐
PAT 乙等 1009 C语言
The author believes that the so-called industrial Internet is a process of deep integration of industry and the Internet
MySQL面试真题(二十五)——常见的分组比较场景
What is the reason for the black screen of the computer monitor when the computer is turned on? What should I do about the black screen of the computer monitor
PAT 乙等 1021 个位数统计
PAT 乙等 1014 C语言
PAT 乙等 1018 C语言
工作积累-判断GPS是否打开
Wechat applet: production and generation of love guarantee
PAT 乙等 1011 C语言
[proteus simulation] Arduino uno+pcf8574+lcd1602+mpx4250 electronic scale
Heimdall database proxy scale out 20 times
数字藏品——新的投资机遇
如何指定pig-register项目日志的输出路径
Yingjixin launched 4 series of lithium batteries 100W mobile power supply voltage rise and fall scheme SOC chip ip5389
云原生数据库是未来
Wireshark TS | 视频 APP 无法播放问题
June 22, 2022: golang multiple choice question, what does the following golang code output? A:3; B:1; C:4; D: Compilation failed. package main import ( “fmt“ ) func mai
jvm-04.对象的内存布局
iNFTnews | 加密之家从宇宙寄来的明信片,你会收到哪一张?