我正在开发一个Android应用程序,我想在其中集成一个Facebook 发布功能。我下载了Facebook-Android SDK,然后 readme。Md(文本文件)在那里,其中提到要生成 Android的键散列。我如何生成它?


当前回答

下载openSSL for windows,你可以在这里找到64位和32位的 解压缩下载的文件 在C盘中创建文件夹名为openSSL 将所有提取的项目复制到openSSL文件夹(bin,include,lib, openSSL .cnf) 获取android调试密钥库,默认位置为

C:\Users\username\.android\ debug.keystore

现在获得命令提示符并粘贴这段代码

keytool -exportcert -alias androiddebugkey -keystore C:\Users\username.android\debug.keystore |“C:\openSSL\bin\openssl” sha1 -binary |“C:\openSSL\bin\openssl” base64

按enter键,你会得到28位的键码

其他回答

我创建了一个适用于Windows和Mac OS x的小工具,只需放入密钥存储文件,并获取散列密钥。

如果您想要默认调试。Keystore文件,使用默认别名和密码。否则,使用您自己的密钥存储库文件和值。

看看吧,下载Windows版或Mac OS X版 (Dev-Host有时可能会宕机…所以如果链接坏了,PM我,我会修复它)。

我希望这对你们有帮助……

2014年12月31日-编辑: 更改主机为AFH。 如果链接坏了,请告诉我

2013年11月21日-编辑:

根据用户的要求,我添加了一个默认的密钥存储库位置和一个捐赠按钮。如果我帮了你,尽管用吧。:)

以下是步骤

Download openssl from Google code (If you have a 64 bit machine you must download openssl-0.9.8e X64 not the latest version) Extract it. create a folder- OpenSSL in C:/ and copy the extracted code here. detect debug.keystore file path. If u didn't find, then do a search in C:/ and use the Path in the command in next step. detect your keytool.exe path and go to that dir/ in command prompt and run this command in 1 line- $ keytool -exportcert -alias androiddebugkey -keystore "C:\Documents and Settings\Administrator.android\debug.keystore" | "C:\OpenSSL\bin\openssl" sha1 -binary |"C:\OpenSSL\bin\openssl" base64 it will ask for password, put android that's all. u will get a key-hash

欲了解更多信息,请访问这里

你需要通过keytool为android签名应用程序创建一个密钥库,就像android站点中描述的过程一样,然后你必须安装cygwin,然后你需要从谷歌代码安装openssl,然后只需执行以下命令,你就会得到android的哈希密钥,然后把哈希密钥放入你创建的facebook应用程序。然后你可以通过Android应用程序访问facebook应用程序的张贴墙(“publish_stream”)可以是一个例子。

$ keytool -exportcert -alias alias_name -keystore sample_keystore。Keystore | openssl sha1 -binary | openssl base64 . Keystore | openssl sha1 -binary

您需要从cygwin执行上面的命令。

要生成释放密钥的散列,请在Mac或Windows上运行以下命令,替换释放密钥别名和密钥存储库的路径。

在Windows上,使用:

keytool -exportcert -alias <RELEASE_KEY_ALIAS> -keystore <RELEASE_KEY_PATH> | openssl sha1 -binary | openssl base64

这个命令应该生成一个28个字符的字符串。记住,复制并粘贴这个释放键哈希到你的Facebook应用ID的Android设置。

图片:fbcdn-dragon-a.akamaihd.net/hphotos-ak-xpa1/t39.2178-6/851568_627654437290708_1803108402_n.png

参考网址:https://developers.facebook.com/docs/android/getting-started#release-key-hash和http://note.taable.com

最好的方法是使用以下代码:

private void getHashKey(String pkgName)
{
    try
    {
        PackageInfo info = getPackageManager().getPackageInfo(pkgName, PackageManager.GET_SIGNATURES);
        for (Signature signature : info.signatures)
        {
            MessageDigest md = MessageDigest.getInstance("SHA");
            md.update(signature.toByteArray());
            String hashKey = Base64.encodeBytes(md.digest());
            _hashKey_et.setText(hashKey);
            Log.i("KeyTool", pkgName + " -> hashKey = " + hashKey);
        }
    }
    catch (NameNotFoundException e)
    {
        e.printStackTrace();
    }
    catch (NoSuchAlgorithmException e)
    {
        e.printStackTrace();
    }
}

但我很沮丧,因为没有简单的工具来为Facebook应用程序生成HashKey。每次我都必须使用Openssl和Keytool,或者使用代码从签名中获得哈希值……

所以我写了一个简单的KeyGenTool,将为您做这项工作:-> KeyGenTool谷歌播放<-

享受:)