Get Facebook key hash the right way

What is Facebook key hash?

Facebook key hash is a 28 character string that is created by applying a cryptographic hash function to a public key. Facebook use it to authenticate the exchange of information between your app and Facebook. Without configure this, your Facebook integration may not work properly.

How to get my key hash?

Let’s try some ways that I listed below:

1. Use keytool utility

On Windows

Running these commands below, the key hash is stored in the file base64.txt
C:\Users\Me>keytool -exportcert -alias <RELEASE_KEY_ALIAS> -keystore <RELEASE_KEY_PATH> -storepass <RELEASE_KEY_PASSWORD> > mycert.bin
C:\Users\Me>openssl sha1 -binary mycert.bin > sha1.bin
C:\Users\Me>openssl base64 -in sha1.bin -out base64.txt

On Linux or Mac OS X

keytool -exportcert -alias <RELEASE_KEY_ALIAS> -keystore <RELEASE_KEY_PATH> | openssl sha1 -binary | openssl base64

2. Use Java code

See my sample code on GitHub

3. Use my Android Keytool

I have a guide in previous blog. You can read this guide here.

References: Stack Overflow

Nhận xét

Bài đăng phổ biến từ blog này

Xe buýt và rau muống

Học làm thơ cho ngày đặc biệt

Phòng chống dịch "Óc Chó"