Integrity checking of android classes.dex and APK Package
How to use:
Check the integrity of classes.dex file with crc32 with checkDexCrcValue() (1) First, the code of calculating its own hash value in apk is implemented. (2) Calculate the hash value of our apk with the sha1sum command under ( for example) Linux. The commands are as follows: shasum verification.apk
Save the hash value generated in (2) to the blockchain, and then get the integrity comparison from the blockchain in our code.
We use checkDexCrcValue() method of calculating crc32 and hash value to check the classes.dex file and the integrity of the whole apk respectively. Of course, the two methods can also be used interchangeably.
Integrity check is that we use various algorithms to calculate the integrity of a file to prevent the file from being modified. The common method is to calculate the CRC32 value of a file or the hash value of a file. We can also use this method to prevent APK from being decompiled. We know that classes.dex generated by APK is mainly generated by Java files. It is the logical implementation of the whole apk. So we can check the integrity of the classes.dex file to ensure that the logic of the whole program is not modified. If we want to ensure the integrity of the entire apk file, we can also check the integrity of the entire apk file. Next, we implement the integrity checking of classes.dex file and APK file respectively.