Created
February 27, 2019 02:37
-
-
Save KwabenBerko/5512c029d0b6fb61ee6d1d4c517557b6 to your computer and use it in GitHub Desktop.
Generate Hash Key
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
public void generateHashkey(){ | |
try { | |
PackageInfo info = getPackageManager().getPackageInfo( | |
"YOUR_PACKAGE_NAME", | |
PackageManager.GET_SIGNATURES); | |
for (Signature signature : info.signatures) { | |
MessageDigest md = MessageDigest.getInstance("SHA"); | |
md.update(signature.toByteArray()); | |
Log.d(Constants.TAG, "HASH BELOW"); | |
Log.d(Constants.TAG, Base64.encodeToString(md.digest(), | |
Base64.NO_WRAP)); | |
} | |
} catch (PackageManager.NameNotFoundException e) { | |
Log.d(Constants.TAG, e.getMessage(), e); | |
} catch (NoSuchAlgorithmException e) { | |
Log.d(Constants.TAG, e.getMessage(), e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment