hash key different through code and cmd for android facebook app-id

909 Views Asked by At

i develop one app in that i require to add hash key in my facebook application, but i got different hash key in two different way, it possible to have two hash key, what hash key i used for my app ?

i Got first hash key through cmd :

fire on cmd :

 keytool -exportcert -alias androiddebugkey -keystore "C:\Users\MAC\.android\debug.keystore" |        "C:\Users\MAC\openssl-0.9.8k_WIN32\bin\openssl.exe" sha1 -binary | "C:\Users\MAC\openssl-0.9.8k_WIN32\bin\openssl.exe" base64

 got hash key : xNHUpu0sITqehvLuV2H3z9zettE=

Second hash key i got through following code :

try {
          PackageInfo info = getPackageManager().getPackageInfo(
          "com.fb.project",  //Replace your package name here
          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));
                System.out.println("key hash = "+ Base64.encodeToString(md.digest(),                      Base64.DEFAULT));
          }
    } catch (NameNotFoundException e) {
        e.printStackTrace();

  } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
  }


  got hash key : 2jmj7l5rSw0yVb/vlWAYkK/YBwk=

So, my problem is that which hash key i used for my app ?

2

There are 2 best solutions below

0
On

yes you can get different keys.Especially in windows so it's better to get the key programmatically.well the case is that both keys will work but if your phone has facebook native app installed then the key generated using cmd will give error.So it's better to use the key generated via program.you can read more at facebook developer site

0
On

"2jmj7l5rSw0yVb/vlWAYkK/YBwk=" is the SHA1 hash of a null input, so if you're getting something like this, you are actually hashing nothing.