Protecting non class resources in jar?

i have a lot of precious artwork and sound files in my java game which i don’t want stolen, i have put them in a jar file but they are very easy to get (.gif, .png .wav, etc)

how would i protect them so it would make it harder for “little above average joe” to access them?

First off, copyrights are enforceable. If you ever find that someone has stolen your images, sounds, or software, you can file a suit against them and potentially receive significant damages. Most lawyers will be more than happy to take a case like that in exchange for a cut of the damages awarded.

That being said, the best thing you can do is to try to make the data harder to decode. Renaming the files to some unknown extension would be the easiest thing you could do. (Most people browsing the file would probably not realize that they’re just PNGs and WAVs.) The next best thing would be packing the files into your own custom container format. And the absolute best “security-through-obscurity” method is to rework the files into your own custom format.

The later method is most popular in the gaming industry. By using a custom format, game makers are able to create files suitable for memory mapping, files with better compression, or files with features specific for their game. Very few “hackers” are going to bother decoding your format. (Too lazy.)

An example of a custom format for space saving can be found here.

Some time ago I tought about developping an image writter with the image IO API by simple prepending some weird header at the beginning of the image file. This way when you load your images you simply skip the kind of signature and continue with the rest of the bytes as usual. That’s not very secure but at least it prevents the “little above average joe” (very funny expression ;D) to reuse your images.

And if you want to be more strong you can use some sort of simple encoding like Base64 in your custom header.

Cryptography no less. DES ISAC Twofish. These are that funny things. You might add also dongle and some other nasty things. Don’t forget to add a lawyer and you are all set.

I’d advise against crypto - the key must be stored alongside the data files, making the whole thing pointless. Dongles are one option, but if you want to be really safe, you’ll need to be deploying to a known JVM on a known configuration on a known OS - not good for a publically-distributed application.

No, rely on lawyers to protect your assets from blatent theft, and dissuade the casual crackers with a simple fix like those mentioned above.

unfortunately, it doesn’t much matter how many ways you try to hide your images, the second you’re rendering them to the screen… anyone can use the “print screen” key (and most average joe’s know that “amazing!!” button…) and then the image is theirs.