I mainly don’t want my resources ‘bluntly’ out in the open
Now I know I can’t fully stop people from grabbing/editing the resources but I’d like to remove the ‘bluntly’ part and possibly store everything in “Cache files” (.dat etc)
Never thought of that
Wouldn’t they just need to rename the .dat to .zip though? XD
I’ll fiddle around with some ideas tonight in my IDE
EDIT:
How would I ‘casually’ go about storing a .png in a .dat file (Encoded, see below)
Beautiful charset output: 3cÿrBR·ÒçÓW~ò$ãÔ€ä5Al½ô
I really advice against doing this because it is much more trouble than it is worth, but you can do something really simple, like this:
Compress your resources (loosely) into a ZIP archive
Apply a simple encryption algorithm (really simple, since the purpose here isn’t to ‘keep them out’ so much as it is to making it not so blunt to acquire access to the resources. Also, the encryption algorithm is entirely local so there isn’t much in the way of someone tearing apart your usage of the Java encryption API and grabbing the key if they really wanted it anyway…) So (in this example) XOR encryption.
Decorate a FileInputStream (to the Zip Archive containing your resources) with an XorDecryptionInputStream (basically just applies an XOR to every byte you read from the stream to decrypt it. A simple one byte key is entirely sufficient for these purposes) and pass that to the ZipInputStream
Use the ZipInputStream as you would.
XOR encryption isn’t that great, and there are flaws (you have to avoid NULL bytes etc) but assuming you just want to make the archive unreadable\unrepairable, it should work fine for your purposes.
Also, with XOR Encryption
Original XOR Key = Encrypted
But
Original XOR Encrypted = Key.
So if they know what the data is supposed to be, your key is exposed. And they can figure out some signature in a Zip Archives Filesystem.
But all that is besides the fact, since security isn’t an issue here.
This idea in its rawest form is:
Export a .png to a .txt file.
Encode / encrypt the .txt file.
Change the format to from .txt to .dat.
How would I go about doing that?
// get .png
// pack .png into .zip
// I'm now lost.
Sorry, maybe I should’ve stated my progress / familiarity with encryption / decryption + exporting haha.
The most I’ve done:
DES Cipher encryption / decryption of strings.
Exporting a images pixels to a .txt file with encryption applied.
Importing a image via encrypted pixels.
I made a program that:
Takes the resource (.png) than imports the raw .png data for encryption prior to exporting it into the cache.dat file
Next thing I need to think about is how to retrieve a certain object in the .dat cache file, should I use resource headers?
(The headers will be encrypted also ^_^)
Here is the cache.dat file contents (pseudo):
Note:
Since I can’t post the encrypted data on the text area on JGO and successfully click post, here are the links
I’m happy with the output, there’s no tenfold on the encryption files size.
Old encryption output for 87kb png: 500KB. New encryption output for 87kb png: same size.
Simply using a non-standard file extension is going to cut out most people. You could always not include the first few header bytes (which makes the format obvious) and that would knock out a bunch more. You’re now down to programmers than can be bothered to decompile your code…which no matter what you do they can walk around.
If you want to kick-it-up to the next level I’d suggest using a 7zip like compression library…at least that way you get something productive (better compression ratios).
Encrypting is simply a waste of your & the CPUs time and doesn’t reduce the number of people that get to your data, so don’t bother.