Suggestion/question: Text encryption

Started by GarageGothic, Mon 02/02/2004 13:24:25

Previous topic - Next topic

GarageGothic

A few times when I've been stuck in AGS games, I've viewed the program files in a text editor and been able to find game messages that helped me past the puzzle. But while this is sometimes a great feature when you're stuck, it's also a problem if you want to hide "secret" information in a game message (say you're having a contest where the first player to find a hidden message and contact you can win something). Obviously you could just show the text as a background image, so there are plenty solutions, but is there any chance that in-game text will ever be encrypted in the game files?

BlackBaron

I don't think that'd be hard to do, but I don't think it's actually needed.

Since you actually have to open the gamefiles with a text editor, that information is just like the walkthroughs that are around the net: if you want to look at them and ruin your fun, that's your problem, if you want to find things out the "right" way just avoid looking for additianal info.

I mean, that feature could be nice, but some willpower can solve the problem too.  ;)
"Do you thirst for knowledge no matter the cost?"
            -Watrik, master glassblower

Kweepa

#2
BB, I think you missed the point - in a competition, requiring willpower to prevent cheating isn't really fair.

GG, you could write some kind of encoding using scripting. The message could be in an integer array, scrambled - then to print it, just unscramble, shove into string, and print.

Probably adding a random sequence of ints to the ASCII values for the characters in the string would be enough.

eg

Code: ags

int scrambled[16], key[16];

scrambled[ 0 ] = 'M' + 72;
scrambled[ 1 ] = 'e' + 44;
scrambled[ 2 ] = 's' + 53;
scrambled[ 3 ] = 's' + 27;
scrambled[ 4 ] = 'a' + 99;
scrambled[ 5 ] = 'g' + 102;
scrambled[ 6 ] = 'e' + 67;
scrambled[ 7 ] = 0;

key[ 0 ] = 72;
key[ 1 ] = 44;
key[ 2 ] = 53;
key[ 3 ] = 27;
key[ 4 ] = 99;
key[ 5 ] = 102;
key[ 6 ] = 67;
key[ 7 ] = 0;

// make this big enough to hold the message
string unscrambled = "                ";

int i = 0;
while (scrambled[i] > 0)
{
   StrSetCharAt(unscrambled, i, scrambled[i] - key[i]);
   i++;
}
StrSetCharAt(unscrambled, i, 0);

DisplaySpeech(EGO, unscrambled);


It wouldn't deter a serious hacker, but what serious hacker is going to devote HOURS to working out how the compiled bytecode of AGS works, where the bytecode for your scrambling routine is, and then what algorithm you've used is, for a presumably cheap prize?

EDIT: For some reason, this board insists on buggering up code. How do I quote code?
Still waiting for Purity of the Surf II

BlackBaron

Well yes, that's indeed a case were encoded text is actually a need. You're right, I missed that point.

Quote
EDIT: For some reason, this board insists on buggering up code. How do I quote code?

I'm not sure what you mean.
There's a checkbox where you write message that disables smiles so the it appears exactly as you write it; if you mean what I think you do, checking that box solves the problem.
"Do you thirst for knowledge no matter the cost?"
            -Watrik, master glassblower

Kweepa

#4
Quote from: BlackBaron on Tue 03/02/2004 18:41:05
There's a checkbox where you write message that disables smiles so the it appears exactly as you write it; if you mean what I think you do, checking that box solves the problem.

Cheers - that would solve half of it. Anyone got any idea about the tabs though?

EDIT: Doh! Thanks Proskrito.
Still waiting for Purity of the Surf II

Proskrito

i think you mean this:
Code: ags
 blah 

use  [ code ] and [ /code ] tags : ) (without the spaces), just like the quote ones

BlackBaron

Thanks  ;D.
I didn't know that either.

As they say, you learn one new thing every day.

Cheers!

(Sorry for the offtopic post).
"Do you thirst for knowledge no matter the cost?"
            -Watrik, master glassblower

GarageGothic

SteveMcCrea, thanks for the script example. That certainly would get the trick done. I might end up using that method if I don't settle for a background or sprite text. It seems a bit complicated for long messages.

My post was more of a question for CJ really, whether encryption was something he'd considered.

Ishmael

I would wrap up a program to encrypt my messages, if I used that.

I think I would do it in QB, making it to output the encrypted text into a .txt file so it would be easy to copypaste from there then...

just a thougth...
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Kweepa

Putting text on an image!
Doh! Why didn't I think of that?
Still waiting for Purity of the Surf II

Ishmael

The encryption would allow translating aswell... the image method might complicate it...
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Pumaman

This is a possibility, yes. Translation files are already encrypted so that the player can't just load one up and see all the in-game text that easily.

Some basic encryption could be added to global messages and room messages easily enough - as you say, I wouldn't aim to stop a determined hacker, just to stop a casual cheat from seeing the text.

Encrypting strings used in the text script would be more difficult though, as the script engine would need to be updated to support it.

GarageGothic

Thanks for the reply Pumaman. In other words, in-game messages could be encrypted, but object names and such wouldn't be? I think that's probably enough. Most of the spoilers come from the messages. I doubt much could be gathered from reading a few words out of context.

Kweepa

CJ -
Couldn't you add some basic XOR encryption to the whole exe and the dat file that was removed on startup?
Still waiting for Purity of the Surf II

SMF spam blocked by CleanTalk