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:
k
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.
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 :
If command successfully work then you will see this command :
Enter keystore password : typeyourpassword
Encryptedhashkey**
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 :)
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=**
=============================================================
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();
}
}
Please follow these step, I hope your key working properly:
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.
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