android - APK checksum- Binary Code Protection -
How do I calculate my APK file checks in Android? I want to calculate APK checksum and want to compare my app. Is executed to see if someone has modified the binary code? How can I check my yoga and achieve it?
Here's some code to check your APK. I wrote and added tampered detections on my apps (which did not include APK checksum in irony).
Private static long millerphilkakex (reference reference) {string APKPath = reference.GetPackCodePath (); Long nick = null; Open the {// file and create the CRC 32 checksum FileInputStream fis = New FileInputStream (new file (APKPath)); CRC 32 CK = new CRC 32 (); CheckedInputStream cis = new checksInststream (FIS, CK); Byte [] Chef = new byte [80]; While (cis (buff)> = 0); Chakmam = ChakGate Value (); } Hold (exception e) {e.printStackTrace (); } Return Chaksam; }
You can also use it in your APK Sha-256 ...
public static string getApkFileDigest (reference reference) {string epachepath = Context.getPackageCodePath (); Try {byte [] hashed = getDigest (new FileInputStream (apkpath), "SHA-256"); Return Base64.encodeToString (hashed, base64.default); } Catch (throwable thrownable) {throwable.printStackTrace (); } Return tap; } Public static ending ending BUFFER_SIZE = 2048; Public stable byte [] getDigest throws throwable (InputStream, string algorithm) (Messagedigest md = MessageDigest.getInstance); {Digest inputstream disk = try new digest inputstream (in, MD); byte [] buffer = new Byte [BUFFER_SIZE]; while (dis.read (buffer)! = -1) {} dis.close ();} Finally {in.close ();} Return md.digest ();}
< / Pre>
Comments
Post a Comment