博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
android SHA1获取(代码获取)
阅读量:2122 次
发布时间:2019-04-30

本文共 1022 字,大约阅读时间需要 3 分钟。

代码获取当前apk使用的签名文件SHA1
publicstatic 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 (NameNotFoundException e) {        e.printStackTrace();    } catch (NoSuchAlgorithmException e) {        e.printStackTrace();    }    return null;}

转载地址:http://xwfrf.baihongyu.com/

你可能感兴趣的文章
PAT1090 Highest Price in Supply Chain 树DFS
查看>>
(PAT 1096) Consecutive Factors (质因子分解)
查看>>
(PAT 1019) General Palindromic Number (进制转换)
查看>>
(PAT 1073) Scientific Notation (字符串模拟题)
查看>>
(PAT 1080) Graduate Admission (排序)
查看>>
Play on Words UVA - 10129 (欧拉路径)
查看>>
mininet+floodlight搭建sdn环境并创建简答topo
查看>>
【linux】nohup和&的作用
查看>>
Set、WeakSet、Map以及WeakMap结构基本知识点
查看>>
【NLP学习笔记】(一)Gensim基本使用方法
查看>>
【NLP学习笔记】(二)gensim使用之Topics and Transformations
查看>>
【深度学习】LSTM的架构及公式
查看>>
【深度学习】GRU的结构图及公式
查看>>
【python】re模块常用方法
查看>>
剑指offer 19.二叉树的镜像
查看>>
剑指offer 20.顺时针打印矩阵
查看>>
剑指offer 21.包含min函数的栈
查看>>
剑指offer 23.从上往下打印二叉树
查看>>
剑指offer 25.二叉树中和为某一值的路径
查看>>
剑指offer 26. 数组中出现次数超过一半的数字
查看>>