1. Hey! Guest! The 36th GMC Jam will take place between February 27th, 12:00 UTC - March 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice
  2. NOTICE: We will be applying a Xenforo update on Tuesday 25th of February. This means that from approximately 10:00 to 14:00 BST the forums will be offline (or possibly longer). Sorry for the inconvenience! Official Announcement here.

GM:S 1.4 How to encrypt .ini files?

Discussion in 'Programming' started by Whirlpoolio, Oct 10, 2017.

  1. Whirlpoolio

    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!
     
    Eclip5e likes this.
  2. NazGhuL

    NazGhuL NazTaiL

    Joined:
    Jun 20, 2016
    Posts:
    538
    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.
     
  3. YellowAfterlife

    YellowAfterlife ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ Forum Staff Moderator

    Joined:
    Apr 21, 2016
    Posts:
    2,506
    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)
     
  4. Whirlpoolio

    Whirlpoolio Guest

    How would I use this? I don't really delve into ini and ds maps so could you show an example?
     
  5. NazGhuL

    NazGhuL NazTaiL

    Joined:
    Jun 20, 2016
    Posts:
    538
    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";
     
    Eclip5e likes this.
  6. yes, ds_map is the way to go
     
  7. camerakid

    camerakid Member

    Joined:
    Jun 20, 2016
    Posts:
    255
    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
     
  8. PNelly

    PNelly Member

    Joined:
    Jun 20, 2016
    Posts:
    257
    Unless there's new information on the functions I'm not aware of, ds_map_secure_save/load() will discourage casual tinkerers but it's important to remember that it doesn't provide real security.

    You can see this thread on the archived GMC for details: http://gmc.yoyogames.com/index.php?showtopic=579075&hl=ds_map_secure#entry4635272

    If someone's got something new on that issue I'd appreciate hearing about it, I don't want to spread misinformation.
     

Share This Page