Sei sulla pagina 1di 3

http://stackoverflow.

com/questions/5306009/facebook-android-generate-key-hash/12405323#12405323

How to create Facebook Hash Key in android ?


This is simple process to generate Hash key and we already create lots of time but again we forget that how to generate Hash key ? Even i am stupid one
of them and again throw same query in Google. But Now i remember whole the process to generate hash key. When you start to create new
Facebook application for android they ask Hash Key to validate your application.

Most of the time user confused to generate Hask key and Key Store , They confused that from where to start ? It mean which path should be use to generate
key?

How to Generate android (Facebook ) Hash Key ?

Step 1 : Download OpenSSL for Windows


Step 2 : Open the drive where you have install JDK. ,(in my case that is C:\)
Step 3 : Extract your Open SSL zip here in root directory (in my case C:\Program Files\)
Step 4 : Copy : JAVA > JDK 1.7.0_25 > bin
Step 5 : Open Command prompt , Start > Run > CMD
Step 6 : Now CMD will show Users location (in my case C:\Users\chintan >_)
Step 7 : Using Step 4 paste that copied path here and enter ,
So it looks like this C:\Users\chintan > cd C:\Program Files\Java\jdk1.7.0_25\bin
Enter , so that will switch to new location. So now you should be here C:\Program Files\Java\jdk1.7.0_25\bin >_
Step 8 : Now start from here ,

8.1
8.2
8.3

keytool -export -alias myAlias (set alias name any)


C:\Users\chintan\.android\debug.keystore ,(Get your Debug key store path and append after alias )

C:\openssl-0.9.8k_WIN32\bin\openssl sha1 -binary(Get your openssl path and append after keystore path
separate with "|") 8.3 C:\openssl-0.9.8k_WIN32\bin\openssl enc -a -e (append with "|")
So , whole URL should looks like ,

Step 9 : Enter if you are ready to get Hash Key :)


C:\Program Files\Java\jdk1.7.0_25\bin >keytool -export -alias myAlias keystore C:\Users\chintan\.android\debug.keystore | C:\openssl-0.9.8k_WIN32\bin\openssl sha1 -binary
| C:\openssl-0.9.8k_WIN32\bin\openssl enc -a -e

Check three parts in your environment.


1.

2.

where is "debug.keystore"?
find / -name "debug.keystore"
if you can't find it, check you eclipse or ADT.

what is alias name?


keytool -list -v -keystore "PATH_TO_DEBUG_KEYSTORE"
3. Check if installed openssl
openssl
If everything is ready, it should prompt for password

In order to generate key hash you need to follow some easy steps.
1) Download Openssl from: here.
2) Make a openssl folder in C drive
3) Extract Zip files into this openssl folder created in C Drive.
4) Copy the File debug.keystore from .android folder in my case (C:\Users\SYSTEM.android) and paste into JDK bin Folder in my
case (C:\Program Files\Java\jdk1.6.0_05\bin)
5) Open command prompt and give the path of JDK Bin folder in my case (C:\Program Files\Java\jdk1.6.0_05\bin).
6) Copy the following code and hit enter
keytool -exportcert -alias androiddebugkey -keystore debug.keystore > c:\openssl\bin\debug.txt
7) Now you need to enter password, Password = android.
8) If you see in openssl Bin folder, you will get a file with the name of debug.txt
9) Now either you can restart command prompt or work with existing command prompt
10) get back to C drive and give the path of openssl Bin folder
11) copy the following code and paste
openssl sha1 -binary debug.txt > debug_sha.txt
12) you will get debug_sha.txt in openssl bin folder
13) Again copy following code and paste
openssl base64 -in debug_sha.txt > debug_base64.txt
14) you will get debug_base64.txt in openssl bin folder
15) open debug_base64.txt file Here is your Key hash.

OLD ANSWER (Generating Keyhash using openssl )


1.
2.
3.
4.
5.
6.

to generate signature you need openssl installed on your pc. If you dont have one download opensslfrom here
In C: , Create openssl folder
extract the contents of downloaded openssl zip file into openssl folder in C:drive
open Command prompt
move to bin of openssl i.e C:\openssl\bin in command prompt
run the following command to generate your keyhash. While generating hashkey it should ask you password.
keytool -exportcert -alias androiddebugkey -keystore "C:\Users\Anhsirk.android\debug.keystore" | openssl sha1 -binary |
openssl base64

NOTE: in the above code note that , you need to give your path to user ( i.e in my case it is C:\Users\Anhsirk , you just need to
change this for your user account.
Give password as android
. If it dont ask for password your keystore path is incorrect.
If everything works fine, it should give you the hashkey below.

II. Create key hash release for facebook


1. Download Openssl from: http://code.google.com/p/openssl-for-windows/downloads/list download openssl-0.9.8e_X64
2. Make a openssl folder in C drive
3. Extract Zip files into openssl folder
4. Start -> Run: cmd (press enter)
5. (press) cd C:\Program Files\Java\jdk1.6.0_45\bin. Note: C:\Program Files\Java\jdk1.6.0_45\bin: is path to jdk folder in your
computer
6. (press) keytool -exportcert -alias gci -keystore D:\folder\keystorerelease | C:\openssl\bin\openssl sha1 -binary |
C:\openssl\bin\openssl base64. Note: D:\folder\keystorerelease: is path to your keystorerelease
7.

Enter keystore password: This is password when your register keystorerelease.


Then you will have a key hash: jDehABCDIQEDWAYz5Ow4sjsxLSw=

8.

Login facebook. Access to Manage Apps. Paste key hash to your app on developers.facebook.com

Potrebbero piacerti anche