Created
April 11, 2019 10:03
-
-
Save iniyanmurugavel/761efc0c64600e8bc7a9a20cbe0b089c to your computer and use it in GitHub Desktop.
Facebook Hashkey Generation in Java code
This file contains hidden or 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
| public void getHashkey() { | |
| try { | |
| PackageInfo info = getPackageManager().getPackageInfo(getApplicationContext().getPackageName(), PackageManager.GET_SIGNATURES); | |
| for (Signature signature : info.signatures) { | |
| MessageDigest md = MessageDigest.getInstance("SHA"); | |
| md.update(signature.toByteArray()); | |
| Log.i("Base64", Base64.encodeToString(md.digest(), Base64.NO_WRAP)); | |
| } | |
| } catch (PackageManager.NameNotFoundException e) { | |
| Log.d("Name not found", e.getMessage(), e); | |
| } catch (NoSuchAlgorithmException e) { | |
| Log.d("Error", e.getMessage(), e); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment