Giving out the source code to your game so that other people may learn from
it is a nice thing. But there are times when people examine your code to
get secret passwords, plot lines, and special codes. You, as a game
designer would not really want that to happen unless it really is intention
to give out hints and cheats.
There are many ways of encrypting game information. What I am about to present is away of encrypting user input so that even the most able programmer cannot find the necessary input by turning the program code inside-out.
Let's suppose you have in your arcade game a password input dialog box (probably to a specified level) or a very hard riddle. You might want to encrypt the password or the answer to the riddle so that the player cannot find the answer by examining your code. You can use elementary ciphers and encryption systems but they are decipherable particularly for the determined player. What you need is a one-way encryption-encryption that cannot practically be deciphered.
Look at the following function, which encrypts a text into its corresponding encrypted numeric value.
Given the encrypted value, it would be extremely hard (but not impossible) to find the original. It is solvable if you use the brute-force method-such as trying out all the combinations for a simple mechanical lock. Yet it would take a computer testing 3 billion combinations a second almost two centuries to test all possible combinations for a simple 8-character password. I don't think there is any faster way of finding the original text, since this is like solving a mathematical multi-variable equation using only one equation.
Variations of this method can be developed but be sure that the method you use would give values that would fit the long integer data type for reasonable lengths of text.
How do you implement this
one-way encryption? You first obtain the encrypted value for the target
input, such as the actual answer to a riddle. You then save this value as
data or hard code it into the program. That way, the original is nowhere to
be found in your game. You then program the game to encrypt whatever input
the player enters. The game will then compare this encrypted value with the
original value and the player has the answer if the two match.
Following is a demo program demonstrating this password encryption. I challenge you to find the password!
Copyright © 1997-1998, SEAV Softwares. All rights reserved.
Eugene Villar (SEAV); e-mail: email@example.com
Visit my web site: SEAV Softwares Web Site