Skip to content

Instantly share code, notes, and snippets.

@px-amaac
Created October 27, 2014 19:40
Show Gist options
  • Save px-amaac/c1e5f853de05c33983f3 to your computer and use it in GitHub Desktop.
Save px-amaac/c1e5f853de05c33983f3 to your computer and use it in GitHub Desktop.
Run this to get the SHA1 for your particular signature. I use for google maps, google plus and facebook and others to ensure that i have the right key
try {
PackageInfo info = getPackageManager().getPackageInfo(
"com.testing.yourPackageName",
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));
textView.setText(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