[英]Can any one help me to understand why I'm getting two different Key hashes?
I found two different methods to get the key hash for an android application: 我发现了两种不同的方法来获取Android应用程序的密钥哈希值:
public void generateHashkey() {
try {
PackageInfo info = getPackageManager().getPackageInfo(
"package_name",//TODO: change to your package name.
PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.d("Signature", Base64.encodeToString(md.digest(),
Base64.NO_WRAP));
}
} catch (PackageManager.NameNotFoundException e) {
Log.d("Signature", e.getMessage(), e);
} catch (NoSuchAlgorithmException e) {
Log.d("Signature", e.getMessage(), e);
}
}
keytool -exportcert -alias alias_name -keystore keystore_path | openssl sha1 -binary | openssl base64
Now my question is: I'm getting two different key hash from these two methods, why so? 现在我的问题是:我从这两种方法中得到了两个不同的密钥哈希,为什么呢?
If these methods return two different hashes, which one should I use? 如果这些方法返回两个不同的哈希值,我应该使用哪一个?
As I register my app on FB with hash generated by using the 2nd method and when I try FB login in my app(live/production) it is asking for hash generated by the 1st method. 当我使用通过第二种方法生成的哈希值在FB上注册我的应用程序时,当我尝试在我的应用程序(实时/生产)中使用FB登录时,它正在询问通过第一种方法生成的哈希值。
Are you possibly using different hashing algorithms? 您是否可能使用其他哈希算法? Your code shows you are using one version of the SHA hash your command line is specifically asking for SHA1?
您的代码显示您正在使用一种版本的SHA哈希,您的命令行专门要求使用SHA1?
This discussion of hashing options may help you. 哈希选项的讨论可能会对您有所帮助。
What specific hash algorithm does MessageDigest.getInstance("SHA") return? MessageDigest.getInstance(“ SHA”)返回什么特定的哈希算法?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.