接入facebook登录和分享时需要在facebook后台添加密钥散列,下面是生成方式
- 第一种(简单,准确)记住要用相应的签名文件进行签名哦
try {
PackageInfo info = getPackageManager().getPackageInfo(
getPackageName(), //Insert your own package name.
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 (PackageManager.NameNotFoundException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
- 第二种(命令行)
- keytool工具装了jdk的都有
- openssl要去网上下载,记住要下载0.98e那个版本的,不然是错误的!!!
keytool -exportcert -alias 签名文件别名 -keystore 签名文件绝对路径 | openssl的路径\bin\openssl sha1 -binary | openssl的路径\bin\openssl base64
标签:md,code,openssl,签名文件,密钥,Android,散列
From: https://www.cnblogs.com/maowuge/p/16599735.html