Last active
August 29, 2015 14:07
-
-
Save thedoapps/5e5e9472788bd00a957a to your computer and use it in GitHub Desktop.
Generate key hash for Facebook - Android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/**generate key hash facebook**/ | |
EditText txt_key_fb = (EditText) findViewById(R.id.txt_fb); | |
try { | |
PackageInfo info = getPackageManager().getPackageInfo( | |
getPackageName(), PackageManager.GET_SIGNATURES); | |
for (android.content.pm.Signature signature : info.signatures) { | |
MessageDigest md; | |
md = MessageDigest.getInstance("SHA"); | |
md.update(signature.toByteArray()); | |
String something = new String(Base64.encode(md.digest(), 0)); | |
txt_key_fb.setText(something); | |
} | |
} catch (PackageManager.NameNotFoundException e1) { | |
Log.e("name not found", e1.toString()); | |
} catch (NoSuchAlgorithmException e) { | |
Log.e("no such an algorithm", e.toString()); | |
} catch (Exception e) { | |
Log.e("exception", e.toString()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment