본문 바로가기

Programming/Android

해쉬키(hash key), 해쉬값이 다른값이 나오거나, 맞지 않을경우 (카카오톡 API, 페이스북 API)

카카오톡 SDK 사용할때 (혹은 페이스북 등등..)

developers 사이트에 해쉬키(Hash Key)를 등록해 주어야 하는데,

카카오톡 가이드에 따르면,


 keytool -exportcert -alias androiddebugkey -keystore -storepass android -keypass android | openssl sha1 -binary | openssl base64

로 해쉬값을 얻을 수 있다고 한다.



하지만 이 명렁어로 해쉬키를 얻어서 진행해보면 진행이 안된다고 나온다!

디버그를 해보면, 비교하는 키 값과, 해쉬 키값이 다르다는 것을 확인할 수 있다.


검색해 봤을때 여러 방법이 있었는데, 대부분의 방법도 같은 잘못된 해쉬 값을 출력 했다.

(맥, 리눅스 에서는 정상적으로 된다는 이야기가 있었습니다!)


Stackoverflow에서 키 생성할때 다음과 같은 방법으로 진행 해보라는 조언이 있었고!

Kakao DevTalk 에서 발견해서 다행히 성공적으로 해결했습니다!!


안되시는 분은 한번 진행해 보시길 추천드립니다!



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.





기존 명령어와 다른점은, 기존 명령어는 한번에 키값을 암호화하고 변환하는데

위 방법은 순차적으로 변환하고 있습니다.

즉 or 연산을 이용해서 만든 값에 문제가 있고, 가이드 대로 할시 안될 경우에 테스트 해보시면 좋을듯 합니다.


https://devtalk.kakao.com/t/topic/623/18

http://stackoverflow.com/questions/5306009/facebook-android-generate-key-hash