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 ?
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