简体   繁体   English

适用于Android Facebook应用的哈希键

[英]Hash key for android facebook app

I'm trying to generate Key hash to incorporate Facebook Application in my Apps. 我正在尝试生成密钥哈希值,以将Facebook Application合并到我的Apps中。

The problem is that; 问题是;

I'm actually getting the right key hash, but i'm still getting the wrong app key hash. 我实际上得到了正确的密钥哈希,但是我仍然得到了错误的应用程序密钥哈希。 (Maybe I'm not taking the right part from the whole key..) (也许我没有从整个键中拿出合适的部分。)

Any help will be very appreciated, I'm pretty lost here... 任何帮助将不胜感激,我在这里迷路了...

Problem Fixed! 问题已解决! :

Just needed to get rid of the "=" sign after copying the key from the CMD. 从CMD复制密钥后,只需摆脱“ =”符号即可。

Please let us know how you are getting your Key-Hash. 请让我们知道您如何获取密钥哈希。 If from keytool , then let us know the procedure, may be we will be able to fix, what are your missing. 如果从keytool ,那么让我们知道程序,也许我们将能够修复,您还缺少什么。

In the meantime you can use the following code to get the Key-Hash. 同时,您可以使用以下代码来获取密钥哈希。

private void getAppKeyHash() {
    try {
        PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES);
        for (Signature signature : info.signatures) {
            MessageDigest md;

            md = MessageDigest.getInstance("SHA");
            md.update(signature.toByteArray());
            String something = new String(Base64.encode(md.digest(), 0));
            Log.d("Hash key", something);
        } 
    }
    catch (NameNotFoundException e1) {
        // TODO Auto-generated catch block
        Log.e("name not found", e1.toString());
    }

    catch (NoSuchAlgorithmException e) {
        // TODO Auto-generated catch block
        Log.e("no such an algorithm", e.toString());
    }
    catch (Exception e){
        Log.e("exception", e.toString());
    }

}

Now from the logcat you can find the Key-Hash. 现在,您可以从logcat中找到Key-Hash。 For more info Please check it form facebook-sdk 有关更多信息,请从facebook-sdk中检查它

Problem Fixed! 问题已解决! :

Just needed to get rid of the "=" sign after copying the key from the CMD. 从CMD复制密钥后,只需摆脱“ =”符号即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM