查找已签名应用程序的密钥哈希

发布于 2024-11-04 05:53:14 字数 160 浏览 1 评论 0原文

我已经签署了我的应用程序并将其导出到桌面上名为 app 的文件夹中,该文件夹中是我的应用程序本身和密钥库。我如何找到可以复制到 Facebook 开发者页面的密钥哈希。我已经安装了 openssl,但似乎无法生成密钥哈希,我尝试了堆栈上的许多其他线程,但似乎没有一个有帮助,谢谢

James

I have signed my app and exported it to a folder on my desktop called app in this folder is my app itself and the keystore. How do i find the key hash that i can copy into the facebook developers page. i have openssl installed but cant seem to generate the key hash ive tried many other threads on stack and none have seemed to help, thanks

James

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

甲如呢乙后呢 2024-11-11 05:53:14
  1. 您应该知道您的密钥库文件在哪里。对我来说是 C:\Users\Selvin\Desktop\selvin.kp
  2. 您应该知道密钥库中的别名。对我来说是 selvin
  3. 你应该知道 keytool 的路径。 C:\Program Files\Java\jdk1.6.0_22\bin\keytool.exe
  4. 您应该知道 openssl 的路径。 C:\OpenSSL-Win32\bin\openssl.exe
  5. 您应该知道密钥库的密码。对我来说是 ***** 呵呵

那么,你应该打电话:

C:\Program Files\Java\jdk1.6.0_22\bin\keytool.exe" -exportcert -alias selvin -keystore c:\users\selvin\desktop\selvin.kp | C:\OpenSSL-Win32\bin \openssl sha1 -二进制 | C:\OpenSSL-Win32\bin\openssl base64

和别名。

将我的路径和别名替换为正确的路径

输入密钥库密码:

输入您的密码,您应该得到如下内容: NfhDlIH7XWJzUZRjL+pZySrMX1Q=

EDITED: NfgDlIG7XWJzUZRUL+bZySrMX1Q= <- is一个糟糕的哈希值。或者你太幸运了,你的钥匙和你的钥匙发生了同样的碰撞

错误:keytool错误:java.lang.Exception:别名不存在

如果哈希不起作用:

首先,调用

C:\Program Files\Java\jdk1.6.0_22\bin\keytool.exe" -exportcert -alias selvin -keystore c:\users\selvin\desktop\selvin.kp

输入密码并读取错误

如果您不记得您的别名keytool错误:java.lang.Exception:别名不存在我使用selvinn来显示错误

。您的所有条目/别名的列表:

C:\Program Files\Java\jdk1.6.0_22\bin\keytool.exe -list -keystore c:\users\selvin\desktop\selvin.kp

第二次编辑

在此处输入图像描述

  1. You should know where is your keystore file. For me is C:\Users\Selvin\Desktop\selvin.kp
  2. You should know your alias in keystore. For me is selvin
  3. You should know path to keytool. C:\Program Files\Java\jdk1.6.0_22\bin\keytool.exe
  4. You should know path to openssl. C:\OpenSSL-Win32\bin\openssl.exe
  5. You should know password to keystore. For me is ***** hehe

Then, you should call:

C:\Program Files\Java\jdk1.6.0_22\bin\keytool.exe" -exportcert -alias selvin -keystore c:\users\selvin\desktop\selvin.kp | C:\OpenSSL-Win32\bin\openssl sha1 -binary | C:\OpenSSL-Win32\bin\openssl base64

Replace my path and alias with proper ones.

Then you should see:

Enter keystore password:

Enter your password and you should get something like this: NfhDlIH7XWJzUZRjL+pZySrMX1Q=

EDITED: NfgDlIG7XWJzUZRUL+bZySrMX1Q= <- is a bad hash. Or you got so lucky that your key made the same collision as

error:keytool error: java.lang.Exception: Alias does not exist

If hash not working:

First, call

C:\Program Files\Java\jdk1.6.0_22\bin\keytool.exe" -exportcert -alias selvin -keystore c:\users\selvin\desktop\selvin.kp

Type password and read the error

If you don't remember your alias keytool error: java.lang.Exception: Alias <selvinn> does not exist I used selvinn to show error.

For a list of all your entries/aliases:

C:\Program Files\Java\jdk1.6.0_22\bin\keytool.exe -list -keystore c:\users\selvin\desktop\selvin.kp

second edit

enter image description here

墨离汐 2024-11-11 05:53:14

对于那些仍在苦苦挣扎的人,我发现如果正确遵循这些步骤肯定会起作用,但第一次要正确执行它们可能非常具有挑战性,实际上我发现有时在处理某些别名时指纹的 Base64 转换不起作用(哈希因某种原因被截断)。我编写了各种批处理文件,将已经提到的大部分指令集中在一起,因此我不排除那里存在问题。

然而,本质上大多数人都在 openssl 阶段失败了(要么找不到它,不知道如何使用它,要么 Windows 管道没有正确地将 SHA1 导出的输出链接到 base64 转换输入)。

为了解决这个问题,您可以使用另一种方法,该方法可能更容易遵循和理解。本质上,Facebook API 想要的是用于对 APK 进行指纹识别的 SHA1 哈希的 Base64 表示(编码)。为此,您只需列出密钥库即可:

"C:\Program Files\Java\JRE6\Bin\keytool.exe" -list -v -keystore "Path-to-your-keystore" -storepass "KeystorePassword" > somefile.txt

显然,您需要根据自己的设置更改 keytool 可执行文件的路径,并将“Path-to-your-keystore”和“KeystorePassword”替换为您的密钥库路径和密码!结果应该是在当前文件夹中创建一个文件“sometext.txt”,然后您可以在任何文本编辑器中打开该文件。该文本文件将列出所有密钥库别名及其各自的 MD5 和 SHA1 哈希值(十六进制字符串)。

现在只需找到用于签署 APK 的别名,复制 SHA1 哈希值,然后使用任何在线十六进制到 Base64 转换器将其转换为 Facebook 所需的 Base64 编码格式。您可以通过谷歌搜索“在线十六进制到 Base64 转换器”找到在线转换器。我一直在使用这个,因为你可以将文本文件中的字符串复制并粘贴到提供的框中,它只会删除分隔每个十六进制字节的冒号。

最后一点(有点明显,但是..)仅复制并粘贴十六进制字符串,而不是 SHA1: 前缀!

希望这对某人有帮助;它当然对我有用!

For those still struggling I have found that these steps when followed correctly will certainly work but they can be quite challenging to get right first time, and actually I have found that sometimes the base64 conversion of the fingerprint when dealing with some alias' do not work (the hash gets truncated for some reason). I've written various batch files that pull most of these instructions already mentioned together so I don't rule out a problem there.

However, essentially most people fall down at the openssl stage (either can't find it, don't know how to use it, or Windows piping doesn't correctly chain the output from the SHA1 export to the base64 conversion input).

To get around this you can use an alternative method which is probably easier to follow and understand. Essentially what the facebook API wants is the base64 representation (encoding) of the SHA1 hash used to fingerprint your APK. To do this you can just list the keystore:

"C:\Program Files\Java\JRE6\Bin\keytool.exe" -list -v -keystore "Path-to-your-keystore" -storepass "KeystorePassword" > somefile.txt

Obviously you need to change the path to the keytool executable according to your own setup, and replace "Path-to-your-keystore" and "KeystorePassword" with your keystore path and password! The result should be the creation of a file "sometext.txt" in the current folder which you can then open in any text editor. The text file will list all of the keystore alias' and their respective MD5 and SHA1 hashes as hex strings.

Now just find the alias used to sign your APK, copy the SHA1 hash, and use any online hex to base64 converter to convert it to the base64 encoding format that facebook requires. You can find an online converter by googling "online hex to base64 converter". I've been using this one as you can just copy and paste the string right from the text file in to the box provided and it will just remove the colons that separate each hex byte.

One final point (somewhat obvious but..) only copy and paste the hex string and NOT the SHA1: prefix!

Hope this helps someone; it certainly works for me!

一个人的旅程 2024-11-11 05:53:14

首先我要感谢塞尔文!

这个答案与 Selvin 的答案几乎相同,但我仍然花了 3 个小时才让它工作:P 所以为真正的新手提供了更多教程

如何从密钥库获取 hashKey

  • 首先从谷歌代码安装 OpenSSL 并将其放入您的C:\ 文件夹
    下载链接
  • 找到keytool程序位置(java中默认
    文件夹)
  • 找到密钥库位置(有调试默认值)

位置 keytool C:\Program Files (x86)\Java\jdk1.xxx)\bin\keytool
位置 openssl C:\OpenSSL-Win32\bin\OpenSSL
位置 (debug)keystore C:\Users[usernamepc].android\debug.keystore

在 Windows 中打开 cmd(开始->运行->cmd)并导航到 keytool 位置
或者复制粘贴以下字符串,注意不能使用ctrl+v,而是

cd c:\program files (x86)\java\jdk1.7.0_01\bin

在正确的目录中单击鼠标右键,将此字符串粘贴到cmd行中:

keytool.exe -exportcert -alias androiddebugkey -keystore c:\users\charx\.android\debug.keystore | C:\OpenSSL-Win32\bin\openssl sha1 -binary | C:\OpenSSL-Win32\bin\openssl base64

“C:\OpenSSL-Win32\bin\openssl”是opensssl的路径.exe 将其替换为您的 openssl.exe 的路径,

确保将您的 [usernamepc] 更改为您的电脑名称,正如您在我的例子中看到的那样,它是 charx。此外,java jdk xxxx 的目录取决于您的版本。

cmd 应该显示 hashkey

我的调试文件的哈希密钥是

h1GdQbgB8b/liCG+acmZWkgIRHA=

First i would like to thank Selvin!

This answer is almost identical to Selvin's answer but it still took me 3 hours to get it to work :P so a little more tutorial for the real newbs

How to get a hashKey from a keystore

  • first install OpenSSL from google code and put it in your C:\ folder
    download link
  • find keytool program location (default in java
    folder)
  • find keystore location (there is a debug default value)

location keytool C:\Program Files (x86)\Java\jdk1.xxx)\bin\keytool
location openssl C:\OpenSSL-Win32\bin\OpenSSL
location (debug)keystore C:\Users[usernamepc].android\debug.keystore

open cmd in windows(start->run->cmd) and navigate to the keytool location
or copy paste the following string, note that you can’t use ctrl+v but right mouseclick

cd c:\program files (x86)\java\jdk1.7.0_01\bin

when in the right directory paste this string in the cmd line:

keytool.exe -exportcert -alias androiddebugkey -keystore c:\users\charx\.android\debug.keystore | C:\OpenSSL-Win32\bin\openssl sha1 -binary | C:\OpenSSL-Win32\bin\openssl base64

"C:\OpenSSL-Win32\bin\openssl" is the path of opensssl.exe replace it with your openssl.exe's path

make sure that you change the [usernamepc] of yourto the name of your pc as you can see in my case it’s charx. Also the directory for the java jdk xxxx depends on your version.

cmd should show hashkey

hash key for my debug file is

h1GdQbgB8b/liCG+acmZWkgIRHA=
三生池水覆流年 2024-11-11 05:53:14

Eclipse 的解决方案(适合像我这样的懒人)。

在 Eclipse 中选择任何项目,导出 - Android 应用程序,输入您的密钥通行证等,然后在底部的最后一页上您将看到
MD5:……
SHA1:....

复制 SHA1 字符串并将其粘贴到任何 HEX-Base64 在线转换器中(例如:http:// tomeko.net/online_tools/hex_to_base64.php

恭喜!您已获得 Facebook 开发控制台所需的密钥哈希。

A solution with Eclipse (for lazy people like me).

Select any project in Eclipse, Export - Android Application, enter your key pass etc. and on the last page at the bottom you will see
MD5: ....
SHA1:....

Copy the SHA1 string and paste it in any HEX-Base64 online converter (for example this one: http://tomeko.net/online_tools/hex_to_base64.php)

Congrats! You've got the key hash needed for Facebook Dev Console.

找个人就嫁了吧 2024-11-11 05:53:14

由于某种原因,上述解决方案对我不起作用,但我能够成功生成 keyhash。我正在编写获取签名 apk 的 keyhash 的 10 个最简单的步骤[使用密钥库签名的 apk]

  1. 将以下代码复制到您的活动 [start Activity] 中。此代码应包含在您的 Activity 中,以便您可以在签名 apk 的 Activity 启动时提取正确的密钥哈希。

    private void getHashKey() {
    尝试 {
        PackageInfo 信息 = getPackageManager().getPackageInfo(
                getPackageName(), PackageManager.GET_SIGNATURES);
        for (签名签名:info.signatures) {
            MessageDigest md = MessageDigest.getInstance("SHA");
            md.update(signature.toByteArray());
            Log.e("MY_KEY_HASH:",
                    Base64.encodeToString(md.digest(), Base64.DEFAULT));
        }
    } catch (NameNotFoundException e) {
    } catch (NoSuchAlgorithmException e) {
    } }
    
  2. 您的 AndroidManifest.xml 文件应在其应用程序标记中具有属性 android:allowBackup="true"

  3. 导出您签名的 apk 并将应用安装到您的手机中,然后在调试模式下连接您的手机并打开 usb 调试

  4. 然后转到sdk\platform-tools

  5. 打开命令提示符并输入adb devices 查看您的设备是否已连接。如果设备未列出,请尝试解决该问题,然后再继续下一步。

  6. 然后输入adb logcat >“log.txt”。您的 cmd 屏幕将会挂起。
    不要恐慌。完全正常,因为整个 logcat 正在写入 log.txt

  7. 运行您的应用程序,希望当您认为 getHashKey()
    执行函数,然后在命令提示符下按 ctrl+c 结束日志文件写入。

  8. 现在命令提示符将再次变得响应。现在进入
    您的 sdk\platform-tools 目录,您将看到一个 log.txt 文件
    已创建包含日志的内容。

  9. 现在在文本编辑器中打开它并搜索MY_KEY_HASH:“-----------您的密钥哈希-----”

  10. 将其复制到您的 FB 帐户 或任何您需要的地方,然后制作另一个版本,其中android:allowBackup="false"getHashKey() 函数是
    已删除。

希望这对大家有帮助:)

The solutions mentioned above didn't work for me for some reason but i was able to successfully generate keyhash. I am writing the 10 easiest step to get keyhash of your signed apk [apk signed with keystore]:

  1. Copy the below code into your activity [start Activity].This code should be contained in your activity so that you can extract the proper keyhash when your signed apk's Activity starts.

    private void getHashKey() {
    try {
        PackageInfo info = getPackageManager().getPackageInfo(
                getPackageName(), PackageManager.GET_SIGNATURES);
        for (Signature signature : info.signatures) {
            MessageDigest md = MessageDigest.getInstance("SHA");
            md.update(signature.toByteArray());
            Log.e("MY_KEY_HASH:",
                    Base64.encodeToString(md.digest(), Base64.DEFAULT));
        }
    } catch (NameNotFoundException e) {
    } catch (NoSuchAlgorithmException e) {
    } }
    
  2. Your AndroidManifest.xml file should have the attribute android:allowBackup="true" in its application tag.

  3. Export your signed apk and Install the app in your mobile phone and then connect your phone in debugging mode with usb debugging on.

  4. Then go to sdk\platform-tools

  5. Open command prompt and type adb devices to see whether your device is connected or not. if device not listed then try to fix that issue before continuing to next step.

  6. Then type adb logcat >"log.txt". Your cmd screen will like hanged.
    Dont Panic. Its Perfectly normal as the whole logcat is being written to log.txt.

  7. Run your app and hopefully when you think that the getHashKey()
    function is executed then press ctrl+c on command prompt to end log file writing.

  8. Now the command prompt will become responsive again. Now go into
    your sdk\platform-tools dir and you will see that a log.txt file
    has been created which contains logs.

  9. Now open it in a texteditor and search for MY_KEY_HASH:"-----------Your keyhash-------"

  10. Copy this onto your FB account or whereever you need it and then make another build in which the android:allowBackup="false" and getHashKey() function is
    removed.

Hope this helped everyone :)

游魂 2024-11-11 05:53:14

我不想理会这一切,我看到了 facebook sdk 实际上发送的内容
导出带有临时代码的签名应用程序以显示 facebook error.toString()
在授权中给出了它所寻找的哈希密钥,然后我将其放入我的 Facebook 应用程序中并宾果游戏!

I couldnt be bothered with all this I see what the facebook sdk is actually sending by
exporting my signed App with temp code in place to display facebook error.toString()
in Authorize which gives the hash key its looking for I then put this in my facebook App and bingo !

心不设防 2024-11-11 05:53:14

如果您使用您的 alies,请使用此命令来查找密钥库 alies

keytool -list -v -keystore keystore.jks | keytool -list -v -keystore keystore.jks | findstr“别名创建”

if you use your alies use this command to find keystore alies

keytool -list -v -keystore keystore.jks | findstr "Alias Creation"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文