我可以通过windows中的cmd或eclipse IDE获取SHA-1指纹,但我想在我的应用程序中使用SHA-1指纹,所以我想知道如何通过代码生成SHA-1指纹?
答案 0 :(得分:0)
try {
PackageInfo info = getPackageManager().getPackageInfo(
"com.facebook.samples.hellofacebook",
PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {
}