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


当前回答

我只是为这个确切的目的做了一个工具,即https://keyhash.vaibhavpandey.com/。它比其他任何方法都简单,因为它需要您浏览计算机上的密钥存储库,并输入密码,分别为谷歌和Facebook生成SHA-1十六进制和Base64版本。

不必担心密钥库或密码短语,因为工作完全是在浏览器中完成的,您可以检查网络选项卡,该工具也是开源的https://github.com/vaibhavpandeyvpz/keyhash。

其他回答

以下是步骤

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

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

目前Facebook Android教程中的说明在Windows下并不适用。他们的例子展示了如何将keytool输出输出到openssl,但是如果你在Windows下尝试这样做,由于某些原因输出是无效的。我发现我必须使用中间文件才能让它正常工作。以下是对我有用的步骤:

首先从谷歌下载openssl for Windows。

C:\Users\Me>keytool -exportcert -alias my_key -keystore my.keystore -storepass PASSWORD > mycert.bin

C:\Users\Me>openssl sha1 -binary mycert.bin > sha1.bin

C:\Users\Me>openssl base64 -in sha1.bin -out base64.txt

运行这些命令后,有效的散列存储在文件base64.txt中。复制粘贴到你的Facebook应用设置中。

您可以从SHA-1密钥获得密钥哈希。 这很简单,你需要得到你的SHA-1(签名APK)密钥从Play Store检查下图。

现在复制SHA-1密钥并在这个网站http://tomeko.net中过去,也检查下面的图像以获得您的密钥哈希。

最简单的解决方案:

不加哈希键,实现其他所有东西 当facebook登录被按下,你会得到一个错误说“无效的键哈希。密钥哈希“xxx”不匹配任何存储密钥. ...” 打开facebook应用程序仪表板,并添加哈希值“xxx=”(“xxx”哈希值来自错误+“=”符号)

Linux

开放式终端:

用于调试构建

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

你会发现debug。Keystore来自”。Android "文件夹复制并粘贴在桌面上,并运行上述命令

发布版本

keytool -exportcert -alias <aliasName> -keystore <keystoreFilePath> | openssl sha1 -binary | openssl base64

注意:确保在这两种情况下,它必须要求密码。如果它不要求输入密码,则意味着命令中有错误。