Created
June 13, 2017 20:08
-
-
Save FabioCZ/f77387e3676742203741b1c51baf58c3 to your computer and use it in GitHub Desktop.
Get hash key in code
This file contains hidden or 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 printHashKey(Context pContext) { | |
try { | |
PackageInfo info = getPackageInfo(pContext, 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