Android gets the MD5 value of the APK signature fingerprint (to prevent repackaging) _android

Source: Internet
Author: User
Tags md5 md5 encryption sqlite database stringbuffer

The example in this article describes the implementation of Android acquiring the MD5 value of APK signature fingerprint to prevent repackaging. Share to everyone for your reference, specific as follows:

Make a record (here is only the Java layer signature Check, Java layer is easy to be cracked, I suggest apk reinforcement)

Obtaining the MD5 value for APK signature verification prevents APK from being packaged again.

Let me tell you how to get the MD5 value of the APK signature (there are three ways)

1. Obtain the MD5 value of signature fingerprint by code

/** * MD5 encryption * @param bytestr the content that needs to be encrypted * @return returns the BYTESTR value of MD5/public static Stri
  Ng encryptionMD5 (byte[] bytestr) {messagedigest messagedigest = null;
  StringBuffer Md5strbuff = new StringBuffer ();
    try {messagedigest = messagedigest.getinstance ("MD5");
    Messagedigest.reset ();
    Messagedigest.update (BYTESTR);
    byte[] ByteArray = Messagedigest.digest ();
        for (int i = 0; i < bytearray.length i++) {if (Integer.tohexstring (0xFF & Bytearray[i)). Length () = 1) {
      Md5strbuff.append ("0"). Append (integer.tohexstring (0xFF & Bytearray[i));
      else {md5strbuff.append (integer.tohexstring (0xFF & Bytearray[i]));
  A catch (NoSuchAlgorithmException e) {e.printstacktrace ());
return md5strbuff.tostring (); }

/**
 * Get app signature MD5 value
 *
/Public String getsignmd5str () {
  try {
    PackageInfo PackageInfo = Mactivity.getpackagemanager (). Getpackageinfo (Mactivity.getpackagename (), packagemanager.get_signatures);
    Signature[] signs = packageinfo.signatures;
    Signature sign = signs[0];
    String signstr = encryptionMD5 (Sign.tobytearray ());
    return signstr;
  } catch (Packagemanager.namenotfoundexception e) {
    e.printstacktrace ();
  }
  Return "";
}

2. Keytool Tools

Using the Keytool tool to obtain the signature MD5 information, the following key is a signed file

Copy Code code as follows:
C:\Program files\java\jdk1.8.0_05\bin>keytool-list-v-keystore C:\Users\Administrator\Desktop\key

3. In Eclipse, you can view signature information.

More interested readers of Android related content can view the site: "Summary of the use of Android controls," "The Summary of Android view tips," "Android File Operation tips Summary", "Android operation SQLite Database Skills Summary", " Android operations JSON format Data tips summary, "Android Database Operation skills Summary", "Android programming activity Operation Skills Summary", "Android programming development of SD card operation method Summary", "Android Development and advanced tutorial And the Android resource Operation Skills Summary

I hope this article will help you with the Android program.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.