Hi I have a game made in Java and Slick2d and I have a folder that contains all of my resources (images, sounds, etc) and I was wondering how to encrypt them so people can't edit them? I tried MD5 but I'm not really sure how it works and I'm not worried about people breaking into the code because I have spliced the jar into an exe file. Also if I need to know how to decrypt the files so that they can be used in the code please explain that too.
Asked
Active
Viewed 1,640 times
3
-
MD5 isn't an encryption algorithm. If you encrypt them you will also have to provide a key, and encrypt the key, and encrypt the key of the key, ... – user207421 Feb 27 '13 at 21:59
-
And why can't you put the resources into the JAR file? – user207421 Feb 27 '13 at 23:19
-
If I put the resources in the jar file then it becomes one giant exe which I don't like. I'd like a folder in the program files folder with my game name and all of the .dat files with the game launcher.exe that has the code. – user1883799 Feb 28 '13 at 15:25
3 Answers
2
There is no way to protect the images/resources, all you can do is make it slightly harder. If you deliver your images/resources to the client then they can always decrypt them, after all the client has to display them unencrypted at some point in time.
Btw.: MD5 is a hash-algorithm, it is used to check if data is undamaged.

Bernd Elkemann
- 23,242
- 4
- 37
- 66
-
How do I make it slightly harder? All I want is simple encryption so the average player can't break into it. I realize it's impossible to encrypt from everyone. – user1883799 Feb 28 '13 at 15:26
-
Ok, then you can just use something trivial like this: https://en.wikipedia.org/wiki/Caesar_cipher – Bernd Elkemann Feb 28 '13 at 15:44
1
MD5 is a hash function which is irreversible and two input may produce the same output.
in case the content of the files is not 'secret' you can use MD5 for a verification process, this should be quite easy.
- Create a hashtabe (or just a table) with the hashes of all the resources your application uses
- Once the applet lanched create an hash for each of the files and compare it with your table, if its not the same, someone has changed the content of your jar file.
I'd recommend to keep the hash table within the code so it will be harder to modify

Community
- 1
- 1

Kirill Kulakov
- 10,035
- 9
- 50
- 67
0
If you are using your resources, you have to decrypt them then the client can use them, because they are being used in the game.

Anubian Noob
- 13,426
- 6
- 53
- 75