Facebook SDK Command Android - Key Hash

3

I'm doing the Facebook SDK tutorial for Android and I do not understand this part, which talks about hashes of key to development environments.

Command:

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

Where should I run this command? I tried CMD but it made a mistake.

    
asked by anonymous 22.06.2016 / 22:33

2 answers

6

Hello, you should tell the path where keytool and openssl are on your computer. In my case you are in:

C: \ Program Files \ Java \ jdk1.8.0_91 \ bin \ keytool.exe

C: \ OpenSSL-Win64 \ bin \ openssl.exe

Now just replace, it will look like this:

"C: \ Program Files \ Java \ jdk1.8.0_91 \ bin \ keytool.exe" -exportcert -alias androiddebugkey -keystore% HOMEPATH% .android \ debug.keystore | "C: \ OpenSSL-Win64 \ bin \ openssl.exe" sha1 -binary | "C: \ OpenSSL-Win64 \ bin \ openssl.exe" base64

Once you've done this, you'll need to enter a password, which is android by default.

Ready! Your hash will appear, you should copy everything including the =

    
19.07.2016 / 22:19
7

There are millions of ways to recover this Key Hash.

It serves to identify that only your project is accessing the user's Facebook information as a form of security.

I always broke my mind to recover this key, but I learned a very simple way to do it.

Within the onCreate method, place this code:

try {
    PackageInfo info = getPackageManager().getPackageInfo(
                           getPackageName(),
                           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 (NameNotFoundException e) {

}
catch (NoSuchAlgorithmException e) {

}

Now run your application, in your LogCat (Android Monitor), will appear a code something like this:

KeyHash: nzM5O1NWEmtflcC3vDK2lx3CwcM=

All these numbers and letters are your Hash Key, including the = sign , then you can put it in the Facebook control panel, so that it recognizes your application.

    
22.06.2016 / 22:46