Skip to content

Instantly share code, notes, and snippets.

@100rabhkr
Created September 7, 2018 08:24
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 100rabhkr/bf652014ddeef93b733a9d94c65db995 to your computer and use it in GitHub Desktop.
Save 100rabhkr/bf652014ddeef93b733a9d94c65db995 to your computer and use it in GitHub Desktop.
public static void printHashKey(Context pContext) {
try {
PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
String hashKey = new String(Base64.encode(md.digest(), 0));
Log.i(TAG, "printHashKey() Hash Key: " + hashKey);
}
} catch (NoSuchAlgorithmException e) {
Log.e(TAG, "printHashKey()", e);
} catch (Exception e) {
Log.e(TAG, "printHashKey()", e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment