Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: GarageGothic on Mon 02/02/2004 13:24:25

Title: Suggestion/question: Text encryption
Post by: GarageGothic on Mon 02/02/2004 13:24:25
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?
Title: Re:Suggestion/question: Text encryption
Post by: BlackBaron on Mon 02/02/2004 22:55:33
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.  ;)
Title: Re:Suggestion/question: Text encryption
Post by: Kweepa on Tue 03/02/2004 00:04:58
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


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?
Title: Re:Suggestion/question: Text encryption
Post by: BlackBaron on Tue 03/02/2004 18:41:05
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.
Title: Re:Suggestion/question: Text encryption
Post by: Kweepa on Tue 03/02/2004 18:57:32
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.
Title: Re:Suggestion/question: Text encryption
Post by: Proskrito on Tue 03/02/2004 19:29:10
i think you mean this:
blah
use  [ code ] and [ /code ] tags : ) (without the spaces), just like the quote ones
Title: Re:Suggestion/question: Text encryption
Post by: BlackBaron on Wed 04/02/2004 12:26:12
Thanks  ;D.
I didn't know that either.

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

Cheers!

(Sorry for the offtopic post).
Title: Re:Suggestion/question: Text encryption
Post by: GarageGothic on Thu 05/02/2004 09:53:40
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.
Title: Re:Suggestion/question: Text encryption
Post by: Ishmael on Thu 05/02/2004 18:03:16
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...
Title: Re:Suggestion/question: Text encryption
Post by: Kweepa on Thu 05/02/2004 18:08:07
Putting text on an image!
Doh! Why didn't I think of that?
Title: Re:Suggestion/question: Text encryption
Post by: Ishmael on Thu 05/02/2004 18:47:09
The encryption would allow translating aswell... the image method might complicate it...
Title: Re:Suggestion/question: Text encryption
Post by: Pumaman on Sat 07/02/2004 12:53:25
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.
Title: Re:Suggestion/question: Text encryption
Post by: GarageGothic on Mon 09/02/2004 11:58:56
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.
Title: Re:Suggestion/question: Text encryption
Post by: Kweepa on Mon 09/02/2004 18:07:48
CJ -
Couldn't you add some basic XOR encryption to the whole exe and the dat file that was removed on startup?