I'm sure this has been done before but I cant find it in the applet archives, basically I want users to be able to download my applet and use it but not be able to view the code, at least not in a way that will make any sense to them. I am aware of obfuscation and it is an option. If I could, I would prefer some means of encryption that would encrypt the class file and decrypt it at the very last moment preventing anyone from snooping through the class file. Anyone know of: a. how to do this or b. A tool / API that does this Thanks Dermot
Hi Dermot, Well, since you're working with Applets, the !@#$% sandbox is going to give you some fits with encryption. The reason is, you will have to define a ClassLoader that either reads encrypted bytes or perhaps a SealedObject. Of course when you attempt to define a ClassLoader in an Applet, you're going to get a SecurityException. Here is some sample code if you want to pursue the class encryption path:
This code uses the triple DES algorithm but you can change it to whatever. Note that the salt (key) has to be 24 bytes. I also use a SealedObject for convenience. This will transport easily across the network. Of course you'll have to send the salt in order to decrypt the class or use the default. This is just a framework and a lot more work will have to be done for a production version and you will still have to deal with sandbox. Hope this is somewhat helpful, Michael Morris [ February 04, 2003: Message edited by: Michael Morris ]
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Thanks for the code Michael, looks like a good starting point. I think I'll have to do some serious digging on ClassLoader and how it works in relation to Applets, any ideas or inspiration (be it divine or otherwise) will of course be shared with fellow ranchers. I can�t help but think that people would be really interested in a solution to this problem.
Story like this gets better after being told a few times. Or maybe it's just a tiny ad: