In the Facebook android tutorial we are told to use following code to create a key hash:
keytool -exportcert -alias androiddebugkey -keystore ~/.andro
/**
* Generates the hash key used for Facebook console to register app. It can also be used for other sdks) Method copied from: https://developers.facebook.com/docs/android/getting-started/
*/
public static String printHashKey(Context ctx) {
// Add code to print out the key hash
try {
PackageInfo info = ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
return Base64.encodeToString(md.digest(), Base64.DEFAULT);
}
} catch (NameNotFoundException e) {
return "SHA-1 generation: the key count not be generated: NameNotFoundException thrown";
} catch (NoSuchAlgorithmException e) {
return "SHA-1 generation: the key count not be generated: NoSuchAlgorithmException thrown";
}
return "SHA-1 generation: epic failed";
}