Created
June 21, 2017 03:10
-
-
Save vinhdn/d4a96b016c85340b8228c45402eab6aa to your computer and use it in GitHub Desktop.
Get SHA
This file contains 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
PackageInfo info; | |
try { | |
info = getPackageManager().getPackageInfo("com.you.name", PackageManager.GET_SIGNATURES); | |
for (Signature signature : info.signatures) { | |
MessageDigest md; | |
md = MessageDigest.getInstance("SHA"); | |
md.update(signature.toByteArray()); | |
String something = new String(Base64.encode(md.digest(), 0)); | |
//String something = new String(Base64.encodeBytes(md.digest())); | |
Log.e("hash key", something); | |
} | |
} catch (NameNotFoundException e1) { | |
Log.e("name not found", e1.toString()); | |
} catch (NoSuchAlgorithmException e) { | |
Log.e("no such an algorithm", e.toString()); | |
} catch (Exception e) { | |
Log.e("exception", e.toString()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment