I can\'t figure out how to get the Key Hash required to use the Facebook Android SDK. I figured out that I can use keytool
with these commands:
You have to open a command prompt window. Go to start->run and type 'cmd' and hit enter. Then you have to navigate to the folder where keytool
is (unless it's in your path), and then type that command.
That is, assuming that command is for windows and not linux.
Best way is to generate Key-Hash using code:
public static void generateKeyHash(Context context) {
try {
PackageInfo info = context.getPackageManager().getPackageInfo(
"com.example.user2.testapp",
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 (PackageManager.NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {
}
}
call this method once and generate key-hash, enjoy
You can install Open SSL from here , that should make your command work
you can use code below to get the Hash key :
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) {
Log.e("name not found", e.toString());
} catch (NoSuchAlgorithmException e) {
Log.e("no such an algorithm", e.toString());
}
Reference :
http://limbaniandroid.blogspot.com/2013/04/how-to-get-hash-key-for-integarte.html
C:\Program Files\Java\jdk1.6.0_22\bin\keytool.exe -exportcert -alias "typeYouraliasname" -keystore locationof your keystore | C:\OpenSSL-Win32\bin\openssl sha1 -binary | C:\OpenSSL-Win32\bin\openssl base64