APK - Files

tdocs2

Well-Known Member
Licensed User
Longtime User
Greetings, once more.

Thank you in advance for answering this question.

Topic: APK Files

I understand from a reply from Erel to another posting that Basic4android calls aapt program (part of Android SDK) to add the files to the package (apk).

In some cases, the files themselves have value - they are derivative works, the product of a program that was written to produce the asset (file).

Question:
Is there a way to "encrypt" or a better word, obfuscate these files so that if the apk is unzipped, they are rendered useless?

Any and all help is welcomed.
 

sorex

Expert
Licensed User
Longtime User
you can do that but if they want they can see your encryption decoding code after decompiling the java bytecode files.
 
Upvote 0

tdocs2

Well-Known Member
Licensed User
Longtime User
APK Files

Thank you both, sorex and thedesolatesoul.

The files in my app are quite large. I was looking for a ready made obfuscating mechanism - similar in concept to what B4A does with the code... I did not want to write an encryption algorithm...

I would also be concerned with performance issues on single or double encryption.

Thanks again.

Any further suggestions will be welcomed.
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
not sure how well b4a/java supports byte arrays but what you can do is pkzip the data and strip the pkzip header.

load it into memory, put the pkzip header infront of the loaded data in the byte array and unzip it.

the header always seems to start with...

50,4B,03,04,14
"P","K",...

the last 3 might be the zip version tho so it might differ overthere.

Most people who sneek into datafiles notice that the PK is a zip file so getting rid of that could solve it.

or you could EOR/XOR the entire array with an 8 bit value.

options enough, but like I said if they go decompile they might find out how you decode it again.
 
Upvote 0

tdocs2

Well-Known Member
Licensed User
Longtime User
APK Files

Thank you, sorex.

Although I have been involved in developing some encryption algorithms (PC and mainframe worlds), I do not come close to your techie skills. I would be concerned about creating an unfavorable result from "tinkering" or going under the covers that would affect the performance or behavior of my app.

Apparently in Android, there is no conventional way to obfuscate the assets which become easily available by unzipping the apk.

Once more, thank you.
 
Last edited:
Upvote 0
Top