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


当前回答

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

其他回答

我已经这样做了Linux操作系统和Windows操作系统:

Linux:

下载Openssl 打开终端 keytool -exportcert -alias **myaliasname** -keystore **/home/comp-1/Desktop/mykeystore. xmlJks ** | openssl sha1 -binary | openssl base64

请更改别名和Keystore与它的路径作为您的要求。

终端将询问密钥库的密码。您必须为相同的密钥存储库提供密码。

最后你会得到Release Hashkey。

窗口:

释放Hashkey的步骤:

下载Openssl(从这里下载),我已经下载了64位操作系统,你可以在这里找到更多 解压下载的zip文件到C:只\驱动器 打开命令提示符 "C:\Users\hiren.patel\Desktop\mykeystore. keytool -exportcert -alias **myaliasname** -keystore **"\openssl-0.9.8e_X64\bin\openssl.exe" sha1 -二进制| "C:\openssl-0.9.8e_X64\bin\openssl.exe" base64

请更改别名和Keystore与它的路径作为您的要求。

注意:请将您的详细信息放在我标记的** **之间。

终端将询问密钥库的密码。您必须为相同的密钥存储库提供密码。

最后你会得到Release Hashkey。

Done

facebook开发者网站上的官方文件:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Add code to print out the key hash
    try {
        PackageInfo info = getPackageManager().getPackageInfo(
                "com.facebook.samples.hellofacebook", 
                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 (NameNotFoundException e) {

    } catch (NoSuchAlgorithmException e) {

    }

下载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。

这个方法对我来说很有效,我做了一些观察:

每个SHA1密钥都有一个对应的密钥散列,长度为28个字符,以'='结尾 我尝试过在线工具来获取我的SHA1的哈希键,但这个哈希键从来没有为我工作过。 如果你在windows上安装Open -ssl:Open ssl 我已经在我拥有的所有密钥存储库文件上使用了这个keytool命令,即登台、调试和发布。

keytool -exportcert -alias my_alias_name -keystore "C:\Users\...my_filename.jks" | "C:\Openssl\bin\openssl.exe" sha1 -binary | "C:\Openssl\bin\openssl.exe" base64

注意: 上面的方法总是会给你一个键散列,即使你填错了任何参数。知道你是否得到正确的散列键的技巧是——运行这个命令后,如果提示输入密码,这意味着后续的键是正确的。

不要使用my_filename。密钥存储库,但使用my_filename代替。jks。

这是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页面。