Created
July 6, 2018 15:10
-
-
Save abbasnaqdi/7f8cf4622e0b034448b58e5ed723a227 to your computer and use it in GitHub Desktop.
signature apk check in runtime
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
PackageInfo info = null; | |
try { | |
info = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES); | |
for (Signature signature : info.signatures) { | |
MessageDigest md = null; | |
try { | |
md = MessageDigest.getInstance("SHA"); | |
md.update(signature.toByteArray()); | |
if (!Base64.encodeToString(md.digest(), Base64.DEFAULT).equals("sha sign key")) { | |
//dont match sign key with current app | |
} | |
} catch (NoSuchAlgorithmException e) { | |
e.printStackTrace(); | |
} | |
} | |
} catch (PackageManager.NameNotFoundException e) { | |
e.printStackTrace(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment