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


当前回答

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

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

其他回答

在Android Studio中也解决了我的问题,但方法略有不同。

在Android Studio中获取SHA-1值。

点击它 点击签署报告 sha - 1副本

SHA-1值是这样的 CD: A1: EA: A3:5C: 5 c: 68: FB:费尔南多-阿隆索:0:6 b: E5:5A: 72:64: DD: 26:8D: 44:84 打开http://tomeko.net/online_tools/hex_to_base64.php进行转换 你的SHA1值到base64。这就是Facebook所要求的 生成的哈希 " ********************= " 并复制关键散列 facebook应用程序控制台。

部分答案来自Github链接

目前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应用设置中。

keytool -exportcert -alias androiddebugkey -keystore       C:\Users\pravin\.android\debug.keystore | "H:\OpenSSL\bin\openssl" sha1 -binary | "H:\OpenSSL\bin\openssl" base64

这对我很管用……

步骤:

1) Open command line go to - > java Keytool..... for me C:\Program Files\Java\JDK1.7\bin
2) Download OpenSSL from google
3) paste this with changing your paths -
   keytool -exportcert -alias androiddebugkey -keystore C:\Users\pravin\.android\debug.keystore | "H:\OpenSSL\bin\openssl" sha1 -binary | "H:\OpenSSL\bin\openssl" base64 

    ....................   give proper debug.keystore path and openSSL path .. 

4) Finley it may be ask u password .. so give password -> android   ...
5) you will get 28 characters that will be your has key

以下是步骤

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

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

Simply Open you Main Activity File and create below mention function: try { PackageInfo info = getPackageManager().getPackageInfo( "your.application.package.name", PackageManager.GET_SIGNATURES); for (Signature signature : info.signatures) { MessageDigest md = MessageDigest.getInstance("SHA"); md.update(signature.toByteArray()); Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT)); } } catch (PackageManager.NameNotFoundException e) { } catch (NoSuchAlgorithmException e) { }

1.1运行你的应用程序,这将为你的应用程序生成一个哈希键。

现在,打开日志猫和搜索“KeyHash”和复制哈希键。 一旦你生成了哈希键,你可以删除这个函数。