Reputation: 126
When bundling some images inside a .jar Package (Java+Swing), what is the best way to protect the JPG files inside to prevent users from accessing the package and copying aforesaid images for their own?
Upvotes: 0
Views: 895
Reputation: 17444
You could write some basic code for symmetric encryption/decryption of your images. This would prevent an amateur user from stealing your images, but a hacker will be able to decrypt them all in some hours. For symmetric encryption example see http://www.java2s.com/Code/Java/Security/Basicsymmetricencryptionexample.htm
Upvotes: 0
Reputation: 80633
You can encrypt them before including them in the JAR, then unencrypt right before displaying (or otherwise using) in your app. The trivial implementation of this would require you to bundle the private key with your app, which basically negates the encryption if the 'user' is determined enough. Alternatively, you could download the key off a hosted site when your app launches. Not foolproof and it will drag the performance of your application down.
Or you could split the images into random frames and combine them right before display. Basically obsfucate the data.
There's a million ways to be honest, haha, but really, none of them are foolproof and are bound to be more trouble than its worth. After all you are going to display the image eventually correct? At which point the 'user' can just do a screen grab.
If you are that concerned with your copyrights then I suggest you watermark your pictures, so you have legal recourse if you discover someone using them.
Upvotes: 2
Reputation: 903
You can get the byte representation of the image, and save it with another file extension, or you can encrypt it with the javax.crypto package, but I don't think it's necesary.
Upvotes: -1