我正在开发一个Android应用程序,我想在其中集成一个Facebook 发布功能。我下载了Facebook-Android SDK,然后 readme。Md(文本文件)在那里,其中提到要生成 Android的键散列。我如何生成它?
当前回答
要获得Android密钥哈希码,请遵循以下步骤:
下载OpenSSL for Windows 现在解压缩到C盘 打开CMD提示符 输入cd C:\Program Files\Java\ jdk1.6.0_26\bin 然后只输入keytool -export -alias myAlias -keystore c:\ users \您的用户名\。android\myKeyStore | C:\openssl-0.9.8 k_win32 \bin\openssl sha1 -二进制| C:\openssl-0.9.8 k_win32 \bin\openssl enc -a -e 完成
其他回答
这是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页面。
这个方法对我来说很有效,我做了一些观察:
每个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。
以下是步骤
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
欲了解更多信息,请访问这里
下载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位的键码
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”和复制哈希键。 一旦你生成了哈希键,你可以删除这个函数。
推荐文章
- apk (.apk)和应用程序包(.aab)的区别
- React-Native:应用程序未注册错误
- 如何设置超时在改造库?
- 无法在Windows上从/usr/local/ssl/openssl.cnf加载配置信息
- Android - SPAN_EXCLUSIVE_EXCLUSIVE跨度不能为零长度
- TextView的字体大小在Android应用程序改变字体大小从本机设置
- 如何模拟Android杀死我的进程
- 禁用EditText闪烁光标
- Android Eclipse -无法找到*.apk
- 设置TextView文本从html格式的字符串资源在XML
- 如何允许所有网络连接类型HTTP和HTTPS在Android(9)馅饼?
- Android加载JS包失败
- Android Studio, logcat在应用程序关闭后清理
- 在android中从上下文获取活动
- 无法解析主机"<URL here>"没有与主机名关联的地址