Skip to content

Instantly share code, notes, and snippets.

@quydm
Last active November 11, 2016 08:20
Show Gist options
  • Save quydm/2dd8628939352629fc4771dc39ce77f9 to your computer and use it in GitHub Desktop.
Save quydm/2dd8628939352629fc4771dc39ce77f9 to your computer and use it in GitHub Desktop.
Get Facebook key hash using Android code
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) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment