Skip to content

Instantly share code, notes, and snippets.

@hwshim0810
Created December 14, 2017 02:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hwshim0810/e1ef2c97ffc34e58527943ef9a7ce596 to your computer and use it in GitHub Desktop.
Save hwshim0810/e1ef2c97ffc34e58527943ef9a7ce596 to your computer and use it in GitHub Desktop.
Use for SDK : KeyHash
try {
PackageInfo info = getPackageManager().getPackageInfo("myandroid.package.name", PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
DebugLogger.d("==============================");
DebugLogger.d("KeyHash:" + Base64.encodeToString(md.digest(), Base64.DEFAULT));
DebugLogger.d("==============================");
}
} catch (PackageManager.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