Openssl is not recognized as an internal or external command

匿名 (未验证) 提交于 2019-12-03 02:18:01

问题:

I wish to generate an application signature for my app which will later be integrated with Facebook. In one of Facebook's tutorials, I found this command:

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

In the tutorial, it says that by running this cmd, my process of generating the signature will start.

However, this command gives an error:

openssl is not recognized as an internal or external command 

How can I get rid of this?

回答1:

Well at the place of openssl ... you have to put actually the path to your openssl folder that you have downloaded. Your actual command should look like:

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

Remember, path that you will enter will be the path where you have installed the openssl...hope this helps..:-)

Edit:

you can download openssl for windows 32 and 64 bit from the respective links below:

OpenSSL for 64 Bits

OpenSSL for 32 Bits



回答2:

Use the entire path, like this:

exportcert -alias androiddebugkey -keystore ~/.android /debug.keystore | "C:\openssl\bin\openssl.exe" sha1 -binary | "C:\openssl\bin\op enssl.exe" base64 

It worked for me.



回答3:

Please follow these step, I hope your key working properly:

  1. Step 1 You will need OpenSSL. You can download the binary from openssl-for-windows project on Google Code.

  2. 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.

  3. 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.



回答4:

This is worked for me successfully.

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

Be careful with below path :

  • "C:\Program Files\Java\jdk1.6.0_26\bin\keytool.exe"
  • "D:\keystore\SocialListing" or it can be like this "C:\Users\Shaon.android\debug.keystore"
  • "C:\cygwin\bin\openssl.exe" or can be like this C:\Users\openssl\bin\openssl.exe

If command successfully work then you will see this command :

Enter keystore password : typeyourpassword

Encryptedhashkey**



回答5:

it's late answer but it will help to lazy people like me.. add this code to your Application class, there is no need to download openssl and no need to set the path.. only need is just copy my code.. and keyHash will generated in log.

import com.facebook.FacebookSdk; public class MyApplication extends Application {      @Override     public void onCreate() {         super.onCreate();         FacebookSdk.sdkInitialize(getApplicationContext());         AppEventsLogger.activateApp(this);         printKeyHash();     }      private void printKeyHash() {         try {             PackageInfo info = getPackageManager().getPackageInfo(                     getPackageName(), PackageManager.GET_SIGNATURES);             for (Signature signature : info.signatures) {                 MessageDigest md = MessageDigest.getInstance("SHA");                 md.update(signature.toByteArray());                 Log.i("KeyHash:",                         Base64.encodeToString(md.digest(), Base64.DEFAULT));             }         } catch (PackageManager.NameNotFoundException e) {             Log.e("jk", "Exception(NameNotFoundException) : " + e);         } catch (NoSuchAlgorithmException e) {             Log.e("mkm", "Exception(NoSuchAlgorithmException) : " + e);         }     } } 

and do not forget add MyApplication class in manifest:



回答6:

First navigate to your Java/jre/bin folder in cmd cd c:\Program Files (x86)\Java\jre7\bin

Then use : [change debug.keystore path to the correct location on your system] install openssl (for windows 32 or 64 as per your needs at 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 

So the whole command goes like this : [prompts to enter keystore password on execution ]

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: 


回答7:

I used this code:

This is worked for me successfully.

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


回答8:

use this worked for me. please change your Path

C:\Program Files\Java\jre7\bin keytool -exportcert -alias androiddebugkey -keystore "C:\Users\Ace.android\debug.keystore" | "C:\openssl\bin

\openssl.exe" sha1 -binary | "C:\openssl\bin\openssl.exe" base64



回答9:

Steps to create Hash Key.  1: Download openssl from Openssl for Windows . I downloaded the Win64 version  2:Unzip and copy all the files in the bin folder including openssl.exe(All file of bin folder)  3:Goto to the folder where you installed JDK for me it’s C:\Program Files\Java\jdk1.8.0_05\bin  4:Paste all the files you copied from Openssl’s bin folder to the Jdk folder.  

then go C:\Program Files\Java\jdk1.8.0_05\bin and press shift key and right click and open cmd

C:\Program Files\Java\jdk1.8.0_05\bin>//cmd path  

that is for Sha1 past this
keytool -exportcert -alias androiddebugkey -keystore "C:\User\ABC\.android.keystore" | openssl sha1 -binary | openssl base64
//and ABC is system name put own system name



回答10:

Downloads and Unzip

You can download openssl for windows 32 and 64 bit from the respective links below:

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 

Important change our path Here as well as install open ssl in your system

It's Working No Doubt

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 

Enter keystore password: android

**ZrRtxw36xWNYL+h3aJdcCeQQxi0=** 

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

using Manually through Coding

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();         }      } 


回答11:

For those looking for a more recent location to install a windows binary version of openssl (32bit and 64bit) you can find it here:

http://slproweb.com/products/Win32OpenSSL.html

An up to date list of websites that offer binary distributions is here

http://www.openssl.org/related/binaries.html



回答12:

go to bin folder path in cmd and then run following command

keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | openssl sha1 -binary | openssl base64 

you will get your key hash



回答13:

for windows users download open ssl from google's code repository https://code.google.com/p/openssl-for-windows/downloads/list

After the download, extract the contents to a folder preferably in your c: drive.

Then update your PATH environment variable so you can use the .exe from any location in your command line.

[windows 8] To update your PATH environment variable, click my computer->properties->Advanced System Settings.

Click the Advanced Tab and click the 'Environment Variable' button at the bottom of the dialog then select the Path entry from the 'System Variables' Section by clicking edit.

Paste the path to the bin folder of the extracted openssl download and click ok.

You will need to close and open and command prompt you may have previously launched so that you can load the updated path settings.

Now run this command:

keytool -exportcert -alias androiddebugkey -keystore "C:\Users\Oladipo.android\debug.keystore" | openssl sha1 -binary | openssl base64

You should see the developer key.



回答14:

This works for me:

C:\Users\example>keytool -exportcert -alias androiddebugkey -keystore  "C:\Users\example\.android" | "C:\openssl\bin\openssl.exe" sha1 -binary  | "C:\openssl\bin\oenssl.exe" base64 


回答15:

It is not guaranteed that generating hashkey with this single openssl method will work. If it does not work for me. But thanks for giving me a direction to solve my issue.

Guaranteed Solution : You need to break the whole command in separate commands and have to write output of every execution in file.

You can take the help from the following link :

http://www.helloandroid.com/tutorials/using-facebook-sdk-android-development-part-1

Enjoy :)



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!