Last active
December 9, 2017 20:14
-
-
Save romrozen/90947753fb5450759ff470e262bf2a95 to your computer and use it in GitHub Desktop.
Hash creation for Facebook API.
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
private void generateHash() { | |
try { | |
PackageInfo info = getPackageManager().getPackageInfo( | |
BuildConfig.APPLICATION_ID,// change to the main package name!! | |
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 (PackageManager.NameNotFoundException e) { | |
} catch (NoSuchAlgorithmException e) { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment