Skip to content

Instantly share code, notes, and snippets.

@hu2di
Created April 10, 2017 02:13
Show Gist options
  • Save hu2di/313deee85693b9276674c8bc20ddc262 to your computer and use it in GitHub Desktop.
Save hu2di/313deee85693b9276674c8bc20ddc262 to your computer and use it in GitHub Desktop.
Generate Key Hash for Facebook SDK android
private void getKeyHash() {
try {
PackageInfo info = getPackageManager().getPackageInfo(
"your Application Id",
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 (Exception e) {
e.printStackTrace();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment