Ncrypt

Top  Previous  Next

If you've ever felt the need to encrypt some precious information in your project (like the high scores, some passwords, a few ingenious scripts that are to be executed and so on, you have come to the right place: ncrpyt.wdl provides you a simple way of encoding and decoding any string or number.

 

Please take a look at some encrypted stuff:

 

aum53_ncrypt1

 

I believe that this won't scare the more serious hackers, but it's not too bad either. The encryption and decryption take place inside the ncrypt.wdl file. I have added a test_ncrypt.wdl file as well; this script shows how you can encrypt and decrypt strings and numbers.

 

You will have to include both script files in your main script if you want to test it; press "E" to encrypt two names and their associated high scores, and then press "D" to decrypt the information that was stored inside the highscore.txt file and display it in the screen. Let's examine the test functions briefly:

 

function encrypt_scores()

{

       str_cpy (initial_str, "John"); // first name

       encrypt_string(); // encrypt the first name

       wait (1);

       initial_number = 10403; // first high score

       encrypt_number(); // encrypt the first high score

       wait (1);

       str_cpy (initial_str, "James"); // second name

       encrypt_string(); // encrypt the second name

       wait (1);

       initial_number = 9886; // second high score

       encrypt_number(); // encrypt the second high score

}

 

You should get the names of the players using inkey, and then you should copy them to initial_str. The high scores will need to be copied to initial_number before being encrypted. You can encrypt as many names and numbers as you want; just make sure to have a matching decrypting function; as an example, if you have encrypted a number, and then two strings, the decrypting function should decrypt a number, and then two strings.

 

function decrypt_scores()

{

       open_file(); // open the highscore file

       wait (1);

       decrypt_string(); // decrypt the first name

       str_cpy (name1_str, decrypted_str); // store the first name in a string (name1_str here) before it gets lost

       wait (1);

       decrypt_number(); // the first high score gets to be decrypted inside the decrypted_number variable

       score1 = decrypted_number; // let's store it before it gets lost

       wait (1);

       decrypt_string(); // // decrypt the second name

       str_cpy (name2_str, decrypted_str); // // store the second name in a string (name1_str here) before it gets lost

       wait (1);

       decrypt_number(); // the second high score gets to be decrypted inside the decrypted_number variable

       score2 = decrypted_number; // let's store it before it gets lost

       wait (1);

       close_file(); // I'm done with the decryption, so let's close the file now

}

 

The decrypted strings will last for 1 frame, so copy decrypted_str to name1_str, or to any other string you can think of before it gets lost. The same thing applies to the numbers; they won't last for more than 1 frame inside decrypted_number, so better copy their value to score1 or any other variable that displays the high scores in your game. I have used two texts and a panel for the demo; you will see how the two names and their associated scores are retrieved from the highscore.txt file and displayed on the screen.

 

If you want to customize the encryption process, replace "100" inside the ncrypt.wdl file with any other value ranging from 1 to 128. Please make sure to use the same value for encryption, as well as for decryption.