Create a compression system

Blitz3D Forums/Blitz3D Programming/Create a compression system

Azaratur(Posted 2008) [#1]
How can i create my compression system?
I don't need a good compression, but i want make more difficoult open my file, because i only know in what way are compressed!

Aza


Matty(Posted 2008) [#2]
Very simple method is with 'run length encoding' - useful if your file has many repeated values, although not good if the file does not have many repeated values.


Snarkbait(Posted 2008) [#3]
or just use zlib.


sswift(Posted 2008) [#4]
If all you care about is keeping people from accessing it, and you don't care enough to keep out the real hackers (which simple compression would never accomplish) then you should encrypt it, not compress it.

And all you need to do to do that is xor each byte with some value, and then use that same value to xor it with again when you need to decrypt it.


Dreamora(Posted 2008) [#5]
as long as you don't waste the time with encrypting textures as thats totally pointless. Every noob can just grab them off the datastream to the GPU through which they always will go in pure raw form.


Azaratur(Posted 2008) [#6]
Hi and thanks to answer me,

For sswift: yes i nees to keep some newbye from my files (than i am in this category) :)
For sswift again: with xor do you mean the bolean eXclusive or? Or what? I am a noob can you explain it better?

For Dreamora: I want send a demo version of my game to different person and i want be sure that they can't steal something from my project, i have the copyright but they can take a mesh, changing a little and keep it, or something like this.

I trust only of myself :)

Aza


Dreamora(Posted 2008) [#7]
Then buy something like Molebox.
thats the simplest and fastest solution to your problem as it does anything on its own.

static meshes and textures as well as music thought can always just be ripped out. not the original but the stuff thats sent to GPU and Sound Chips


sswift(Posted 2008) [#8]
Aza:
Bitwise xor.

I don't know if Blitz3D has that operation though. There may be a function in the math section of the code archives here that will do it if not.

You could also just add some number on encrypt and then subtract that number later IF you're working with whatever the int type in Blitz3D is. I think Blitz3D uses longs. So if you load the file as longs, and add 10 then the number will roll over to negative if it's too high, and roll back to positive when you subtract form it again. That's what numbers on computers do when you exceed the highest value they can hold.

But if your file isn't an even multiple of 4 bytes in size then you'll have to stick some zero bytes into that last int, so once again things aren't gonna be so easy for you.


Snarkbait(Posted 2008) [#9]
He could also just use terabit's datapacker which encrypts & packs media into the exe, it's free and easy to use... in the toolbox.