Created
April 7, 2016 18:45
-
-
Save Isabellle/1113a4b409ef55c7b9000573751d5977 to your computer and use it in GitHub Desktop.
Display HashKey in Java
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
public static void showHashKey(Context context) { | |
try { | |
PackageInfo info = context.getPackageManager().getPackageInfo( | |
"com.example.yourpackagename", PackageManager.GET_SIGNATURES); //Your package name here | |
for (Signature signature : info.signatures) { | |
MessageDigest md = MessageDigest.getInstance("SHA"); | |
md.update(signature.toByteArray()); | |
Log.i("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT)); | |
} | |
} catch (NameNotFoundException e) { | |
} catch (NoSuchAlgorithmException e) { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment