简体   繁体   English

有谁能帮助我理解为什么我会得到两个不同的密钥哈希值?

[英]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应用程序的密钥哈希值:

1. Using a Java method: 1.使用Java方法:

 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);
    }
}

2. Fetch form Keystore: 2.获取表单密钥库:

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.

相关问题 我没有得到MapView和确切的位置有人帮助我吗? - i'm not getting MapView and exact location any one help me? 有人可以帮助我理解为什么我需要IF和WHILE来获得这个答案吗? - Can someone help me understand why I need an IF and WHILE for this answer? 任何人都可以帮助我,为什么控制台上没有显示等待线程的情况。 如果我使用 future.get() 方法 - can any one help me out, why else condition not shows over console for waiting Thread. if i'm using future.get() method 无法理解为什么我得到一个空指针错误 - Can't understand why i'm getting a null pointer error 在 maxlines 3 和宽度参数中打印字符串,我不明白,有人可以帮助我 - Print string in maxlines 3 and width parametar, I'm not understand all, can someone help me 我得到 i = 5,但从未达到最后一种情况。 你能帮我理解为什么吗? - I get i= 5, but last case is never reached. can you help me understand why? 任何人都可以帮助我解决Java中的这个错误吗? - can any one help me in this error in java? 当我进入该程序时,对#2和#3的选择将不起作用。 谁能帮助我了解为什么它会以这种方式运行? - When I enter this program, my choices for #2 and #3 will not work. Can anyone help me understand why it is behaving this way? 您能帮我找出此代码中的错误吗? 我似乎不明白为什么它不起作用? - Can you help me identify the error in this code? I dont seem to understand why it isn't working? 我收到以下运行时错误。 请帮我找出原因 - I'm getting the following runtime error. Please help me figure out why
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM