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


当前回答

这是Facebook官方页面上给出的内容:

   keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64

让我把这个命令分解成几个片段。

Look for "keytool.exe". You can search that on the C: drive. You can find it in "java jdk" or "java jre". If you have installed multiple versions, choose any. Open a CMD prompt and go to the above directory where you found "keytool.exe". Clip the "exe`" and paste the above command provided on the Facebook page. You will get an error on entering this that OpenSSL is not recognized as in input output command. Solution : Download "Openssl" from OpenSSL (if you have a 64-bit machine you must download openssl-0.9.8e X64). Extract and save it anywhere... I saved it on the C: drive in the OpenSSl folder Replace the openssl in the above command in which you was getting an error of OpenSSL with "C:\OpenSSL\bin\openssl" at both the places after the pipe, "|". If prompted for a password, enter android.

你会得到你的哈希键。要了解进一步的步骤,请再次参考Facebook页面。

其他回答

这是Facebook官方页面上给出的内容:

   keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64

让我把这个命令分解成几个片段。

Look for "keytool.exe". You can search that on the C: drive. You can find it in "java jdk" or "java jre". If you have installed multiple versions, choose any. Open a CMD prompt and go to the above directory where you found "keytool.exe". Clip the "exe`" and paste the above command provided on the Facebook page. You will get an error on entering this that OpenSSL is not recognized as in input output command. Solution : Download "Openssl" from OpenSSL (if you have a 64-bit machine you must download openssl-0.9.8e X64). Extract and save it anywhere... I saved it on the C: drive in the OpenSSl folder Replace the openssl in the above command in which you was getting an error of OpenSSL with "C:\OpenSSL\bin\openssl" at both the places after the pipe, "|". If prompted for a password, enter android.

你会得到你的哈希键。要了解进一步的步骤,请再次参考Facebook页面。

下载openSSL ->安装它->通常会安装在C:\ openSSL

然后打开CMD并键入

cd../../Program Files (Enter)

java (Enter)

dir (Enter)

cd jdk1.6.0_17 (varies with jdk versions) (Enter)

查看jdk版本到C:/program files/java/jdk_version

cd bin (enter)

keytool -exportcert -alias androiddebugkey -keystore C:Users\Shalini\.android\debug.keystore | "C:\OpenSSL\bin\openssl sha1 -binary | "C:\OpenSSL\bin\openssl base64 (Enter)

它会问你密码是android。

要生成释放密钥的散列,请在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

我犯了一个小错误,应该记住。如果你正在使用你的密钥库,那么给出你的别名,而不是androiddebugkey…

我的问题解决了。现在,如果我的设备上安装了Facebook,那么我的应用程序仍然在Facebook登录集成上获得数据。只关心你的哈希键。

请看下文。

C:\Program Files\Java\jdk1.6.0_45\bin>keytool -exportcert -alias here your alias name  -keystore "G:\yourkeystorename.keystore" |"G:\ssl\bin\openssl" sha1 -binary | "G:\ssl\bin\openssl" base64

然后按Enter -它会要求您输入密码,然后输入您的密钥库密码,而不是Android。

酷。

这是Xamarin的版本


private void printKeyHash()
{
    try
    {
        PackageInfo info = PackageManager.GetPackageInfo(PackageName, PackageInfoFlags.Signatures);
        foreach (var signature in info.Signatures)
        {
            MessageDigest md = MessageDigest.GetInstance("SHA1");
            md.Update(signature.ToByteArray());
            var hash = Base64.EncodeToString(md.Digest(), Base64Flags.Default);
            Log.Debug("KeyHash:", hash);
        }
    }
    catch (PackageManager.NameNotFoundException e)
    {

    }
    catch (NoSuchAlgorithmException e)
    {

    }
}