Wondering about File Reading / Writing

Started by C.T.C.B, Sun 12/05/2013 23:39:26

Previous topic - Next topic

C.T.C.B

Code I have:
[embed=425,349]
//Then check if a User Data File is written. If not, then write it.
if (!File.Exists("$SAVEGAMEDIR$/stats.dat"))
{
  File *output = File.Open("$SAVEGAMEDIR$/stats.dat", eFileWrite);
  output.WriteString("");
  output.Close();
}
}[/embed]

What I want to do:
1.) I want to be able to password protect the file, so only AGS can actually get in and out of it, as this file stores important game data (Including Achievements).
2.) I need a way for the game to be able to load the file again, by having a way to enter the password.

Khris

What you're looking for is encryption (not password protection). There's a module by monkey, and an older one by HeirOfNorton, but the links are all broken.
It's pretty simple to code a basic encryption though.

You'd go through a String character by character, and shift the value using XOR based on a hard-coded password. This operation is reversed when the file is read.
Here's a tutorial for C++: http://www.cplusplus.com/articles/Ly86b7Xj/

SMF spam blocked by CleanTalk