0

I use Window 7 with android studio to build my application. I used in facebook SSO for the login system. I follow the steps as the below tutorial.

How to create Android Facebook Key Hash?

I inputted the command as below into my powershell

$ keytool -exportcert -alias androiddebugkey -keystore "C:\Documents and Settings\Administrator.android\debug.keystore" | "C:\OpenSSL\bin\openssl" sha1 -binary |"C:\OpenSSL\bin\openssl" base64

Then the powershell return a hash shorter than 28 chars, which is not accepted by facebook.

How can I generate a key accepted by facebook?

Community
  • 1
  • 1
Evan Lee
  • 31
  • 1
  • 1
  • 2

3 Answers3

0

You need to use this hashkey generated by below code:

public static void printHashKey(Context pContext) {
    try {
        PackageInfo info = getPackageInfo(pContext, PackageManager.GET_SIGNATURES);
        for (Signature signature : info.signatures) {
            MessageDigest md = MessageDigest.getInstance("SHA");
            md.update(signature.toByteArray());
            String hashKey = new String(Base64.encode(md.digest(), 0));
            Log.i(TAG, "printHashKey() Hash Key: " + hashKey);
        }
    } catch (NoSuchAlgorithmException e) {
        Log.e(TAG, "printHashKey()", e);
    } catch (Exception e) {
        Log.e(TAG, "printHashKey()", e);
    }
}
justDroid
  • 345
  • 2
  • 9
0

I got the same problem when I provided invalid keystore path - no error message, just strange eight-character-long string. Switching path to

C:\Users\Username.android\debug.keystore

solved the problem in my case.

Paweł Krakowiak
  • 346
  • 3
  • 11
0

It happened to me when i use openssl-0.9.8k_WIN32.zip,generated only TenDigitHash== then i returned to using openssl-0.9.8e_WIN32.zip so it generated hash as expected. I am using windows32bit