Here is a 'poor-mans encryption' scheme I used in VisualBASIC and PHP back in the old days before I used PGP, Bluefish, DES, or my own creations. Granted it is not 100% fool-proof, but definitely slows or even stops someone who does not read this forum :) ...
Here is a rough line-by-line breakdown (must be converted to BYOND code, but it is possible) -
-store the save file contents into a variable ($file)
-generate a random number between 1 and 90 - this is your 'key' ($key)
-do a loop through each character in $file, adding the value of $key to that character...
for i=1 to length of $file {
$value = the numeric value of the ASCII character at position i in $file
// for example if the ASCII character is a ' ' (space), then its numeric value is 32)
$new_value = $value + $key // this formula can be changed to anything
$new_char = ASCII character conversion of $new_value
// for example if $new_value = 122, then the ASCII conversion is the letter 'z')
$new_file = $new_file + $new_char
}
-next insert the $key into your $new_file...
$new_file = $new_file + $key
-then store the $new_file on the server
The algorithm isn't bad, but if the result of the key and the character to modify turns out to be an EOF char (00) then you're done for, because BYOND strings terminate at any 00 byte.
Here is a rough line-by-line breakdown (must be converted to BYOND code, but it is possible) -
-store the save file contents into a variable ($file)
-generate a random number between 1 and 90 - this is your 'key' ($key)
-do a loop through each character in $file, adding the value of $key to that character...
for i=1 to length of $file {
$value = the numeric value of the ASCII character at position i in $file
// for example if the ASCII character is a ' ' (space), then its numeric value is 32)
$new_value = $value + $key // this formula can be changed to anything
$new_char = ASCII character conversion of $new_value
// for example if $new_value = 122, then the ASCII conversion is the letter 'z')
$new_file = $new_file + $new_char
}
-next insert the $key into your $new_file...
$new_file = $new_file + $key
-then store the $new_file on the server
this example adds the key to each character in the file, then adds the key to the end (so that reversing the encryption is easy) effectively scrambling the contents of the file unless you know where the $key is located, *and* what formula is used to apply the key to the string. Ideally you want to bury the key somewhere deep in the file, like the 30th or 40th position...someplace where you can extract the $key from the string to be used for decoding...one common method is to split the $file into two strings (the strings being of different lengths), add the key to the first string, then concatenate the two strings together into one string again
The $new_value = $value + $key formula could be replaced with something that XOR's the $value with the $key, or does some other mathematical transform. Even Air Mapsters dec2hex conversion would be useful (although doubling the file size). On the other side (decoding), you just reverse the transformation to get the original value again.
Difficult but not impossible to hack, a simple method of scrambling the content of the file. Couple this with player logs that are reviewed regularly, and you will easily spot anyone who has figured out the code and changed their player file. Vigilance is usually the best defense against crackers. Also if the cracker spends so much time on trying to crack the file, then they are not really interested in playing in the first place (my opinion of course).
Just my two cents...