Legacy GM How to encrypt .ini files?

W

Whirlpoolio

Guest
Hey! I just want to know the easiest but good way to encrypt .ini files. I don't want to play for an extension. I also don't want to use 64bit encoding because anyone can use a translator.
This is my save file script:
Code:
if (file_exists("Save.ini")) file_delete("Save.ini");
ini_open("Save.ini");
// Menu values
ini_write_real("boolean","Human",global.bought0);
ini_write_real("boolean","Miner",global.bought1);
ini_write_real("boolean","Ninja",global.bought2);
ini_write_real("boolean","Disco Yu",global.bought3);
ini_write_real("boolean","SHADOW",global.bought4);
ini_write_real("boolean","KING",global.bought5);
ini_write_real("boolean","SIRE ORE",global.bought6);
ini_write_real("boolean","BROKEN BRACKETS",global.bought7);
ini_write_real("boolean","AAT",global.bought8);
ini_write_real("boolean","LL",global.bought9);

// Money
ini_write_real("money","$$",global.money);
ini_close();
This is my load file script:
Code:
if (file_exists("Save.ini"))
{
    // Menu values
    ini_open("Save.ini");
    global.bought0 = ini_read_real("boolean","Human",0);
    global.bought1 = ini_read_real("boolean","Miner",0);
    global.bought2 = ini_read_real("boolean","Ninja",0);
    global.bought3 = ini_read_real("boolean","Disco Yu",0);
    global.bought4 = ini_read_real("boolean","SHADOW",0);
    global.bought5 = ini_read_real("boolean","KING",0);
    global.bought6 = ini_read_real("boolean","SIRE ORE",0);
    global.bought7 = ini_read_real("boolean","BROKEN BRACKETS",0);
    global.bought8 = ini_read_real("boolean","AAT",0);
    global.bought9 = ini_read_real("boolean","LL",0);
    
    //Money
    global.money  = ini_read_real("money","$$",0)
    ini_close();
}
else
{
    //do nothing
}
Thanks for any help!
 

NazGhuL

NazTaiL
Have you consider the use of ds_map instead of ini? You can use the built-in function:ds_map_secure_save and ds_map_secure_load.
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
Use ini_open_from_string to "open" an INI file from a string, then get the modified string from ini_close. Then find a method for encrypting/decrypting those strings (which is easier than encrypting files)
 
W

Whirlpoolio

Guest
Have you consider the use of ds_map instead of ini? You can use the built-in function:ds_map_secure_save and ds_map_secure_load.
How would I use this? I don't really delve into ini and ds maps so could you show an example?
 

NazGhuL

NazTaiL
Code:
if(file_exists("my_game_settings.sav"))
{
map = ds_map_secure_load("my_game_settings.sav");
}
else
{
map = ds_map_create();
ds_map_add(map, 5, 1);
ds_map_add(map, "level", 100);
ds_map_add(map, 89, "hello world");
ds_map_add(map, "fish", "good");
ds_map_secure_save(map, "my_game_settings.sav");
}
Then
ds_map_find_value(map,"level") will returns 100;
ds_map_find_value(map,89) will returns "hello world";
 

camerakid

Member
Hey Guys,

I'm about to use ds_map_secure_save function in a Steam game but I am a little unsure about the proper usage of this. The manual says "and will be encrypted and stored to a safe location".

I was wondering if I use Steam Cloud function what that "safe location" will be so I can sync that file too?!

Thanks.

Attila
 
Top