keytool 与 Android Facebook SDK

发布于 2024-11-17 11:49:15 字数 1333 浏览 7 评论 0原文

我只是想要一些确认。

我正在 Windows 上进行开发,

我正在尝试将 facebook 集成到应用程序中,SDK 文档说我需要“导出签名”,

从这里: http://developers.facebook.com/docs/guides/mobile/#android

所以它说运行这个命令:

 keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64

首先我必须下载 openssl:OpenSSL< /a>

现在,我认为上面的命令应该转换为:

"C:\path\to\java\keytool" -exportcert -alias your_alias -keystore "C:\path\to\your\keystore\keystore.name" | "C:\path\to\openssl_install\bin\openssl" sha1 -binary |"C:\path\to\openssl_install\bin\openssl" base64
  • 那么您想要将 keytool 安装在最新的 Java 安装文件夹中吗?
  • 您希望别名是您在 Eclipse 中正常创建 apk 时使用的别名吗?
  • 您希望密钥库成为导出 Android 应用程序时使用的密钥库吗?
  • 您希望 openssl 成为您刚刚安装的那个

所以一旦我完成此操作,它会要求输入密码:(它在我输入时显示密码)

如果我输入正确的密码,我会得到

'zR2tey1h9kqPRSW/yEYEr0ruswyD='(已更改为公开)

,但如果我输入错误的密码,它仍然会返回以下形式的代码

'ga0RGNYHvTR5d3SVDEfpQQAPGJ1='?

所以是的,只是在寻找我正在做正确的事情的确认,这是预期的输出

I just want some confirmation.

I'm developing on windows

I'm attempting to integrate facebook into an app and the SDK documentation says I need to 'export a signature'

From here: http://developers.facebook.com/docs/guides/mobile/#android

So it says run this command:

 keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64

First I had to download openssl: OpenSSL

Now the command above, I assume should be converted to:

"C:\path\to\java\keytool" -exportcert -alias your_alias -keystore "C:\path\to\your\keystore\keystore.name" | "C:\path\to\openssl_install\bin\openssl" sha1 -binary |"C:\path\to\openssl_install\bin\openssl" base64
  • So you want the keytool that is installed in your latest Java install folder?
  • You want the alias to be the name of the alias you use for a normal apk creation in eclipse?
  • You want the keystore to be the one you use when exporting android apps?
  • You want openssl to be the one you just installed

So once I've done this it asks for a password: (it shows the password as I'm typing it)

If I enter a correct password I get

'zR2tey1h9kqPRSW/yEYEr0ruswyD=' (changed for public)

but if I enter an incorrect password it still returns me a code in the form of

'ga0RGNYHvTR5d3SVDEfpQQAPGJ1='?

So yeah, was just looking for a confirmation that I'm doing the right thing, and this is the output expected

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

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

发布评论

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

评论(3

前事休说 2024-11-24 11:49:15

获取哈希值的最佳方法是运行以下代码:

try {
            PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES);
            for (Signature signature : info.signatures) {
                MessageDigest md;

                    md = MessageDigest.getInstance("SHA");
                    md.update(signature.toByteArray());
                    String something = new String(Base64.encode(md.digest(), 0));
                    Log.e("hash key", something);
        } 
        }
        catch (NameNotFoundException e1) {
            // TODO Auto-generated catch block
            Log.e("name not found", e1.toString());
        }

             catch (NoSuchAlgorithmException e) {
                // TODO Auto-generated catch block
                 Log.e("no such an algorithm", e.toString());
            }
             catch (Exception e){
                 Log.e("exception", e.toString());
             }

当使用 Windows cmd、git bash 或 cygwing 终端提取哈希值时,这三个工具给出不同的结果。

最准确的是上面的代码

the best way to get your hash is by running the following code:

try {
            PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES);
            for (Signature signature : info.signatures) {
                MessageDigest md;

                    md = MessageDigest.getInstance("SHA");
                    md.update(signature.toByteArray());
                    String something = new String(Base64.encode(md.digest(), 0));
                    Log.e("hash key", something);
        } 
        }
        catch (NameNotFoundException e1) {
            // TODO Auto-generated catch block
            Log.e("name not found", e1.toString());
        }

             catch (NoSuchAlgorithmException e) {
                // TODO Auto-generated catch block
                 Log.e("no such an algorithm", e.toString());
            }
             catch (Exception e){
                 Log.e("exception", e.toString());
             }

when extracting the hash with windows cmd,git bash or cygwing terminal, the three tools give different result.

the most accurate is the code above

夜声 2024-11-24 11:49:15

是的,我认为你的做法是正确的。我还执行这个命令并将这个哈希值放入我的 Facebook 应用程序中,并且它可以正常工作。

yes you are doing it in a right way i think.i also execute this command and put this hash in my fb app and its works properly.

时光瘦了 2024-11-24 11:49:15

下面回答您的问题:

因此,一旦我完成此操作,它就会要求输入密码:(它显示密码
当我打字时)

如果我输入正确的密码,我会得到

'zR2tey1h9kqPRSW/yEYEr0ruswyD='(已更改为公开)但如果我输入
密码不正确,它仍然返回给我以下形式的代码

'ga0RGNYHvTR5d3SVDEfpQQAPGJ1='?所以是的,我只是在寻找一个
确认我正在做正确的事情,这就是输出
预计

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 - 二进制 | openssl base64 具有三个命令,将前一个命令的输出提供给后一个命令。

  1. keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore
  2. openssl sha1 -binary
  3. openssl base64

当给出不正确的密钥库密码时,第一个命令生成错误,但不会显示该错误,因为该错误将输入到第二个命令并生成不同的哈希值。仅运行第一个 keytool 命令 (keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore) 来确认您的密钥库密码以及它是否正确。如果密码不正确,将显示类似以下的输出。

> keytool -exportcert -alias androiddebugkey -keystore 

〜/.android/debug.keystore
输入密钥库密码:
keytool 错误:java.io.IOException:密钥库被篡改,或密码被篡改
不正确

提供android来回答输入密钥库密码:以获取是否生成android调试哈希的提示。 android 调试密钥库的默认密码是 android

命令也可以编写为从 keytool 命令捕获错误,以查看命令 1 在运行命令 2 之前是否返回错误。

所以您需要在最新的 Java 安装中安装 keytool
文件夹?

您希望别名是您在正常情况下使用的别名的名称。
在 Eclipse 中创建 apk?

您希望密钥库是导出 android 时使用的密钥库
应用程序?

您希望 openssl 成为您刚刚安装的那个吗?

对以上所有问题都是肯定的。 PATH 可以设置为不输入 keytool 和 openssl 的完整路径。

Answer to your question below:

So once I've done this it asks for a password: (it shows the password
as I'm typing it)

If I enter a correct password I get

'zR2tey1h9kqPRSW/yEYEr0ruswyD=' (changed for public) but if I enter an
incorrect password it still returns me a code in the form of

'ga0RGNYHvTR5d3SVDEfpQQAPGJ1='? So yeah, was just looking for a
confirmation that I'm doing the right thing, and this is the output
expected

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64 has three commands feeding output of preceding command to following command.

  1. keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore
  2. openssl sha1 -binary
  3. openssl base64

When incorrect keystore password is given, first command generates error but that won't be displayed as that would be input to second command and different hash is generated. Only run first keytool command (keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore) to confirm your keystore password and if it is right. If password is incorrect, similar to output below will be displayed.

> keytool -exportcert -alias androiddebugkey -keystore 

~/.android/debug.keystore
Enter keystore password:
keytool error: java.io.IOException: Keystore was tampered with, or password was
incorrect

Provide android to answer for Enter keystore password: for prompt if android debug hash is generated. Default password for android debug keystore is android

Command could also have written to catch error from keytool command to see if command 1 returned error before running command 2.

So you want the keytool that is installed in your latest Java install
folder?

You want the alias to be the name of the alias you use for a normal
apk creation in eclipse?

You want the keystore to be the one you use when exporting android
apps?

You want openssl to be the one you just installed?

Yes to all of questions above. PATH could be setup not to type full path for keytool and openssl.

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