# keytool with Android Facebook SDK

I just want some confirmation.

I’m developing on windows

• Dagger 2 injecting parameters of constructor
• How to calculate sound frequency in android?
• how to get gps location android
• @OnClick array with optional ids (ButterKnife)
• How can I read a text file in Android?
• How to Enabling ProGuard obfuscation in Android Studio?
• I’m attempting to integrate facebook into an app and the SDK documentation says I need to ‘export a signature’

From here: http://developers.facebook.com/docs/guides/mobile/#android

So it says run this command:

 keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64


First I had to download openssl: OpenSSL

Now the command above, I assume should be converted to:

"C:\path\to\java\keytool" -exportcert -alias your_alias -keystore "C:\path\to\your\keystore\keystore.name" | "C:\path\to\openssl_install\bin\openssl" sha1 -binary |"C:\path\to\openssl_install\bin\openssl" base64

• So you want the keytool that is installed in your latest Java install folder?
• You want the alias to be the name of the alias you use for a normal apk creation in eclipse?
• You want the keystore to be the one you use when exporting android apps?
• You want openssl to be the one you just installed

So once I’ve done this it asks for a password: (it shows the password as I’m typing it)

If I enter a correct password I get

‘zR2tey1h9kqPRSW/yEYEr0ruswyD=’ (changed for public)

but if I enter an incorrect password it still returns me a code in the form of

‘ga0RGNYHvTR5d3SVDEfpQQAPGJ1=’?

So yeah, was just looking for a confirmation that I’m doing the right thing, and this is the output expected

### Related posts:

• android shape with bottom stroke
• Getting Header information with RXJava and Retrofit
• java.lang.UnsupportedOperationException: This is not supported, use MenuItemCompat.setOnActionExpandListener()
• How to set text size in WebView in android
• GSON ignore elements with wrong type
• What is a cheek press event?
• ### 3 Solutions collect form web for “keytool with Android Facebook SDK”

yes you are doing it in a right way i think.i also execute this command and put this hash in my fb app and its works properly.

the best way to get your hash is by running the following code:

try {
PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md;

md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
String something = new String(Base64.encode(md.digest(), 0));
Log.e("hash key", something);
}
}
catch (NameNotFoundException e1) {
// TODO Auto-generated catch block
Log.e("name not found", e1.toString());
}

catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
Log.e("no such an algorithm", e.toString());
}
catch (Exception e){
Log.e("exception", e.toString());
}


when extracting the hash with windows cmd,git bash or cygwing terminal, the three tools give different result.

the most accurate is the code above

Answer to your question below:

So once I’ve done this it asks for a password: (it shows the password
as I’m typing it)

If I enter a correct password I get

‘zR2tey1h9kqPRSW/yEYEr0ruswyD=’ (changed for public) but if I enter an
incorrect password it still returns me a code in the form of

‘ga0RGNYHvTR5d3SVDEfpQQAPGJ1=’? So yeah, was just looking for a
confirmation that I’m doing the right thing, and this is the output
expected

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64 has three commands feeding output of preceding command to following command.

1. keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore
2. openssl sha1 -binary
3. openssl base64

When incorrect keystore password is given, first command generates error but that won’t be displayed as that would be input to second command and different hash is generated. Only run first keytool command (keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore) to confirm your keystore password and if it is right. If password is incorrect, similar to output below will be displayed.

> keytool -exportcert -alias androiddebugkey -keystore


~/.android/debug.keystore
Enter keystore password:
keytool error: java.io.IOException: Keystore was tampered with, or password was
incorrect

Provide android to answer for Enter keystore password: for prompt if android debug hash is generated. Default password for android debug keystore is android

Command could also have written to catch error from keytool command to see if command 1 returned error before running command 2.

So you want the keytool that is installed in your latest Java install
folder?

You want the alias to be the name of the alias you use for a normal
apk creation in eclipse?

You want the keystore to be the one you use when exporting android
apps?

You want openssl to be the one you just installed?

Yes to all of questions above. PATH could be setup not to type full path for keytool and openssl.

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.