我希望为我的应用程序生成一个应用程序签名,以后将与Facebook集成。在Facebook的一个教程中,我发现了这个命令:

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

在教程中,它说通过运行这个cmd,我的生成签名的进程将开始。

但是,这个命令会给出一个错误:

openssl is not recognized as an internal or external command

我怎样才能摆脱这个?


当前回答

如果你在windows上并且安装了git,那么你可以使用git Bash运行open ssl命令。

转到要存储密钥的目录 右键单击并打开GIT Bash 在这里,您可以运行任何openssl命令。如。 openssl enc -aes-128-cbc -k test -P -md sha1

其他回答

首先在cmd中导航到Java/jre/bin文件夹 cd c:\Program Files (x86)\Java\jre7\bin

然后使用:[change debug。]到系统上正确位置的密钥库路径] 安装openssl(适用于Windows 32或64,根据您的需要在c:\openssl)

keytool -exportcert -alias androiddebugkey -keystore "C:\Users\vibhor\.android\debug.keystore" | "c:\openssl\bin\openssl.exe" sha1 -binary | "c:\openssl\bin\openssl.exe" base64

因此整个命令是这样的:[提示在执行时输入密钥库密码]

c:\Program Files (x86)\Java\jre7\bin>keytool -exportcert -alias androiddebugkey
-keystore "C:\Users\vibhor\.android\debug.keystore" | "c:\openssl\bin\openssl.ex
e" sha1 -binary | "c:\openssl\bin\openssl.exe" base64
Enter keystore password:

下载和解压缩

你可以从以下连结下载openssl for windows32及64bit:

https://code.google.com/archive/p/openssl-for-windows/downloads

OpenSSL for 64 Bits OpenSSL for 32 Bits

keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | **"C:\Users\keshav.gera\openssl-0.9.8k_X64\bin**\openssl.exe" sha1 -binary | **"C:\Users\keshav.gera\openssl-0.9.8k_X64\bin**\openssl.exe" base64

重要的改变我们的路径这里以及安装开放ssl在您的系统

毫无疑问,这是有效的

C:\Users\keshav.gera>keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | "C:\Users\keshav.gera\openssl-0.9.8k_X64\bin\openssl.exe" sha1 -binary | "C:\Users\keshav.gera\openssl-0.9.8k_X64\bin\openssl.exe" base64

输入keystore密码:android

**ZrRtxw36xWNYL+h3aJdcCeQQxi0=**

=============================================================

通过编码手动使用

import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.Signature;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;


private void PrintHashKey() {

        try {
            PackageInfo info = getPackageManager().getPackageInfo("**com.keshav.patanjalidemo  Your Package Name Here**", 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) {
            e.printStackTrace();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }

    }

这对我来说很成功。

“C:\Program Files\Java\jdk1.6.0_26\bin\keytool.exe” -exportcert -alias sociallist -keystore “D:\keystore\SocialListing” |“C:\cygwin\bin\openssl.exe” sha1 -binary |“C:\cygwin\bin\openssl.exe” base64

注意以下路径:

“C: \ Program Files \ Java \ jdk1.6.0_26 \ bin \ keytool.exe” “D:\keystore\SocialListing”或者可以是这样的“C:\Users\Shaon.android\debug.keystore” “C:\cygwin\bin\openssl.exe”或者可以像这样:C:\ users \openssl\bin\openssl.exe

如果命令成功工作,那么你将看到这个命令:

输入keystore密码:typeyourpassword

Encryptedhashkey * *

如果你在windows上并且安装了git,那么你可以使用git Bash运行open ssl命令。

转到要存储密钥的目录 右键单击并打开GIT Bash 在这里,您可以运行任何openssl命令。如。 openssl enc -aes-128-cbc -k test -P -md sha1

请遵循以下步骤,我希望你的钥匙工作正常:

Step 1 You will need OpenSSL. You can download the binary from openssl-for-windows project on Google Code. Step 2 Unzip the folder, then copy the path to the bin folder to the clipboard. For example, if the file is unzipped to the location C:\Users\gaurav\openssl-0.9.8k_WIN32, then copy the path C:\Users\gaurav\openssl-0.9.8k_WIN32\bin. Step 3 Add the path to your system environment path. After your PATH environment variable is set, open the cmd and type this command: C:\>keytool -exportcert -alias androiddebugkey -keystore [path to debug.keystore] | openssl sha1 -binary | openssl base64 Type your password when prompted. If the command works, then you will be shown a key.