🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

simple encryption or just useless

Started by
30 comments, last by Sinner_Zero 22 years, 8 months ago
Do you know how to read a file in one character at a time? DO you know how to output one one character at a time? If so, then it''s simple; for each character:

output = input ^ a_number_from_0_to_255

Repeat the process to decrypt.

Why does this work?

If a ^ b = c, then:
a ^ c = b
b ^ c = a

Each character is really a number, 8 bits (1 byte) long. How XOR works is it compares the binary digits (bits) of two numbers, and makes output depending on them. For each bit, it returns 1 if one bit is 1 and the other is 0, and 0 if both are 0 or both are 1. So....

10100110
01110101
11010011

You can XOR (That is, use the "^" operator) every 1st character by the first character of a password, every 2nd by the second letter, and so on, for a form of decent encryption.

If you also XOR by rand() with a seed that is dependent on the password you''ll get even better encryption.

None of the techniques I''ve described are very complicated, so they''re not too difficult to crack, but they''re not bad, so you may want to try them out.
Advertisement
I find your attempts to protect your game data interesting, but it is futile. Im sorry but ive seen games such as Red Alert, StarCraft and Diablo encrypt their MIX files with RSA or use their own proprietary encryption. It usually just slows down the time it takes to load your game and as soon as a cracker like me gets his hand on the .exe and runs it through his el1te h4x1ng tools its too late.

The more you think about it the more you realise that its impossible to hide this. If the game decodes the information, thats enough to let anyone else do it. The code is there, its only compiled into machine code instructions. There are alot of people who can hack this but then we usually spend our time on things that are worth cracking rather than games made by indy developers.

Anyway, keep up the good work and im sure the 30 minutes or so after you release your game you can enjoy the security of knowing people cant read your game data.

CorsairK8
CorsairK8@Fnemesis.comLinux Debian/GNU RulezThis is my signitory!C Is Tha Best!
I find your attempts to protect your game data interesting, but it is futile. Im sorry but ive seen games such as Red Alert, StarCraft and Diablo encrypt their MIX files with RSA or use their own proprietary encryption. It usually just slows down the time it takes to load your game and as soon as a cracker like me gets his hand on the .exe and runs it through his el1te h4x1ng tools its too late.

The more you think about it the more you realise that its impossible to hide this. If the game decodes the information, thats enough to let anyone else do it. The code is there, its only compiled into machine code instructions. There are alot of people who can hack this but then we usually spend our time on things that are worth cracking rather than games made by indy developers.

Anyway, keep up the good work and im sure the 30 minutes or so after you release your game you can enjoy the security of knowing people cant read your game data.

CorsairK8
CorsairK8@Fnemesis.comLinux Debian/GNU RulezThis is my signitory!C Is Tha Best!
Ive just read that post about XOR encryption and that is the easiest to break! All you need is a few bytes of encrypted data and its equivalent few bytes decrypted in memory with a memory debugger. You can then try each of the 255 combinations to see what the key is and then decode the entire thing.
CorsairK8@Fnemesis.comLinux Debian/GNU RulezThis is my signitory!C Is Tha Best!
Right... So if you decode by rand() then your key becomes your randometric seed which you supplied to srand(). If you encrypt data randomly then you cant decode it. If your program can decode it, another program can too. Although it can be fun at times to crack a complicated piece of software, its generally easy unless a developer goes to extreme methods to secure the data.
CorsairK8@Fnemesis.comLinux Debian/GNU RulezThis is my signitory!C Is Tha Best!
Use modular inverses (not sure how that''s called in english). Most encryption algorithms are using that (RSA to name one).

Here is a short example of what I call modular inverses :

(7 * 3) % 10

7 and 3 are such numbers.

If you want to encrypt say, 4, just do this :

(4 * 3) % 10 (gives 2)

Then do decrypt :

(2 * 7) % 10 (gives 4)

It works because (7 * 3) % 10 = 1.

The problem is than this will only work with numbers between 0-9. If you want to encrypt, say, bytes, you''ll have to find inverse numbers in base 256 (num1 * num2) % 256). Just do a bit of math and you''ll find a pair..

Next, if you want, you can add XORing, or XOR and then MOD. Add multiple layers of that, and it becomes harder to break.

Of course, if someone knows the paired values used to encrypt and decrypt, then it''s easy to break. So you should probably obfuscate the key (use a smaller encryption scheme to encrypt the key, just to add confusion, like translation + XOR).

Naturally, a cryptanalyst will break this in a very short time. A file hacker might be very annoyed but probably won''t give up anyway.

Sorry if this makes no sense, I''m tired, and I don''t know english translations of most math terms.

Hope this helps.
Well I''m more confused than a drunken munkey.

now, this ''^'' thinger, I understand it sorta, see now, it compares bits, if theyre equal it returns 1 and if theyre no it returns 0. But you said
a^b=c
so a^c=b
and b^c=a

how is that possible?

wait, ROFL, it does work, thats pretty neat.

as for the anonymous guy, damn.....thats a tough one ot get, sorta, gonna haveto write it down, as I''m sure it''ll make more sense if I understand the actual math concept in it.


But, though those 2 methods are great, is there anyway for me to get my hands on the actualy binary like easier.....

say I have 3 bytes.

01011101 10100010 10010010

now an algorithm I saw did this. it put togethor the bytes

010111011010001010010010

then split them in another spot

0101 1101 1010 0010 1001 0010

and put them back to bytes I assume by filling in any missing bits with 0''s.

how can I get access to the binary''s? I mean I assume I can make my own little thinger that like puts the binary code into like a string and manipulate it from there but is there anything that already does this for you? maybe I should start looking into assembly?

As for encryption not being effective, well, no I don''t see how it''s possible to make an unbreakable encryption, a really tough one to break would take a lot of time including knowlege into knowing how to break them. But frankly I really arent needing to safeguard anything but am just starting to look into encryption. And if it were to be done on a server instead of on the computer directly I don''t see any easy way for the person to crack it then.
Ok, I was just looking into some assembly and saw that (quite simple) they had the regular binary <--> decimal switching code. So assuming C++ can''t regularly do this I can make (this is a sensible way of encryption?) my own int to binary then back to int encryption/decryption no?

though I''m not sure this would necessatily take longer to crack if not shorter, heck I can mix it with XOR and MOD eh?

though the article I saw mention that bit thing called it true 128-bit encryption.......sounds fancy to me, though I''m sure I missed a step.
quote: Original post by Russell
(or until someone invents quantum computers)


Quantum computers already exist. A demonstration of their power was one being used to crack 512bit encryption, which it did... in approximately 0.12 seconds IIRC
-----------------------"When I have a problem on an Nvidia, I assume that it is my fault. With anyone else's drivers, I assume it is their fault" - John Carmack
hm......in my last post there, are those like, sensible ideas?

This topic is closed to new replies.

Advertisement