官方提供的获取散列秘钥的代码
try {
PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES);
for (android.content.pm.Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
String KeyHash = Base64.encodeToString(md.digest(), Base64.DEFAULT);
Log.e("HashKey=========", KeyHash);// 打印出来的HashKey就是秘钥散列
}
} catch (Exception e) {
}
网友评论