Skip to content

Instantly share code, notes, and snippets.

@Scienticious
Last active August 2, 2017 04:41
Show Gist options
  • Save Scienticious/33783f7b52204a76837c263b7dc0cd40 to your computer and use it in GitHub Desktop.
Save Scienticious/33783f7b52204a76837c263b7dc0cd40 to your computer and use it in GitHub Desktop.
try {
PackageInfo info = getPackageManager().getPackageInfo(
getPackageName(),
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) {
}
@Scienticious
Copy link
Author

Get keyhash programmatically in android

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment