我正在开发一个Android应用程序,我想在其中集成一个Facebook 发布功能。我下载了Facebook-Android SDK,然后 readme。Md(文本文件)在那里,其中提到要生成 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。

其他回答

下载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位的键码

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

每个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。

使用它在kotlin中打印键哈希

try {
        val info = context.getPackageManager().getPackageInfo(context.packageName,
                PackageManager.GET_SIGNATURES);
        for (signature in info.signatures) {
            val md = MessageDigest.getInstance("SHA")
            md.update(signature.toByteArray())
            Log.d("Key hash ", android.util.Base64.encodeToString(md.digest(), android.util.Base64.DEFAULT))
        }
    }catch (e:Exception){

    }
This required no coding input. Go to Android Studio-> 
Click on Right side panel "Gradle"=>
*Your App Name =>
*Your App Name(root)=>
*Tasks=>
*android =>
*Double click on **signinReport**=>
Will get 
example :
SHA1: [![6A:DE:ED:5A:9F:0B:19:47:38:DC:DE:3B:7B:A2:D7:4C:6C:0A:24:70][1]][1]

Go to 

http://fbkeyhash.com/index.php
Paste your SHA-1

以下是步骤

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

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