Advertisement

OT: encrypting files

Started by December 05, 2001 05:43 PM
20 comments, last by penetrator 23 years, 2 months ago
i see in some games they encrypt tga files. How can be done ? How can i encrypt/decrypt a .tga or other sort of binary files through a routine ? glHorizon_Project

www.web-discovery.net

You can simply XOR your data by a key value. That''s easy, fast, but relatively simple to hack for a professional.

If you want *real* security, then try one of those:

http://cnscenter.future.co.kr/crypto/algorithm/block.html

Be careful, some of those algorithms are patented in the US, if you plan to distribute your game there. I think that DES, Blowfish and RC4/5/6 are patent free (or the patent has expired), but be careful with IDEA and AES. If your game stays in Europe, then you can just pick any of them.
Advertisement
what means XOR the data ? how do i do that ?

glHorizon_Project



www.web-discovery.net


quote:
Original post by penetrator
what means XOR the data ? how do i do that ?





It means perform the exclusive or operation on each byte of your data. This should be covered in your C book, under bitwise logical operators.
The xor method will work to stop people that have little or no idea about crypto but it would take some one that has even a little bit of knloge about encryption no time at all to crack this (even by hand), but on the + side it is very quick to implement and you will have no legal trouble with this. If you are more serous about protecting your data I would suggest you look up a book called "Applied Cryptography" by Bruce Schneier it is the bible of cryptography.

any way to do the XOR thing that was talked about you simply take a key value and then loop thru your data
and xor it to the key e.g. (this is VERY VERY simplistic but you should get the idea)
  void en(char *data, int Data_size, char key){    for (int i=0; i<Data_size; i++)       data[i] ^= key;}  

There are some library that you can get that will do strong cryptography, I made one that implements several algorithms but I am reluctant to release it with all current political situation.

any way good luck.

Edited by - Validus on December 6, 2001 2:52:21 PM

Edited by - Validus on December 6, 2001 3:08:05 PM

Edited by - Validus on December 6, 2001 6:12:29 PM
Does Microsoft Windows have some kind of built-in cryptography API
interface? Something that can make a program anti-patch proof?
Advertisement
Why would you want to encrypt your images? It creates extra work for your engineers/artists and slows down your game.

If people want your "encrypted" art, they are just going to take screenshots anyway.

Buster, it is a matter of copyright: i''d like to use some .3ds or .tga files which cannot be openly distribuited, so i tought i could encrypt those files ...

glHorizon_Project



www.web-discovery.net


I actually use XOR encryption as one of the many levels of encryption for an encryption program I wrote called K-Crypt. (It''s a great program, BTW. One of these days, I''ll clean up the source code and publish it.)

Here''s the theory behind XOR encryption:

XOR means "Exclusive OR," i.e. if one value or the other is true, but not both, and not neither of them. So

0 ^ 0 = 0
0 ^ 1 = 1
1 ^ 0 = 1
1 ^ 1 = 0

The cool thing about XOR encryption is that it is symmetrical and self-reversible. If you reverse the above equations, they are still true:

0 ^ 0 = 0
1 ^ 1 = 0
1 ^ 0 = 1
0 ^ 1 = 1

So you can essentially use the same function to encrypt and decrypt a lot of bytes using XOR keys. All you do is perform the same operation on many bits:

10011010 ^ 00110101 = 10101111
(original ^ key = encrypted)

10101111 ^ 00110101 = 10011010
(encrypted ^ key = original)

And typically the encryption key will be more than 8 bits, because using the code Validus posted, you could find the encryption key for any chunk of encrypted data by sequentially searching through only 256 possible keys.
[sub]Don''t make fun of it, don''t destroy it, don''t cheapen it......that one special thing that everyone has.My love...my dreams...and you.I won''t let those go, no matter what.[/sub]
got it ! very simple and effective ... thanks !

glHorizon_Project



www.web-discovery.net


This topic is closed to new replies.

Advertisement