I’ve coded a Java app and I plan to distribute it online. Each release will be locked with a secret serial key I made.
I need to secure my jar file from decompiler etc. Here is what I’ve done so far:
- User enters his serial key into a form
- The serial is sent to my dev server through a php script
- The script generates a new jar bin file which is encrypted in AES 128
- My “loader” downloads the jar file as bytes and decrypts it.
- It invokes the main method.
- User can use the app as he like to
- User close the app
- The cache is cleared and everything returns to step 1 or before.
I’ve made the steps 1 to 3, but I need to know if it is possible to make a custom classloader that grabs bytes from HTTP, decrypts them and invokes the main method. As the file is fully crypted (saved as bin on the PHP server), I can’t use a basic class loader. About step 8, is it possible to unload content from the computer’s memory?
Yes, you can provide to a classloader the bytes you grab. I do it in a similar problem :
But this won’t be sufficient to protect your code. At the very least, don’t use the same bytes for two users (you seem to do it). And obfuscate your code (I use proguard). This will protect you against ordinary hackers, not the best ones.