Hey, sorry for the long winded post for a small issue.
Trying to simply find a nice way to save a file of data which can be shared without being modified. This is for a level editor shareable save file.
The main goal is a file which the contents can be freely read, but the game will know if it's been modified or incorrect.
I save a level locally as a text file using a json_encoded DS map. I will add a 'key' string which is simply defined in the game code and create an MD5 of that entire thing to put at the start in the file.
This way, when the file is saved it has the hash and the file data without the key, so people (and me) can freely look at the data (as it doesn't help me at all to just hide it with encoding) and the game will not load a modified (and by extension, incorrect) file.
[HASH of key+data] [DATA]
The only downside with this is people could find out what the key string is since it's just hardcoded into the game... and what if somehow I lost the key? Is there a smarter way to approach this? Some kind of dynamic key that isn't as obvious? I thought of basing it on the string length somehow, something like that. Or maybe I'm just being a total fool? Pretty much the only issue is the key potentially being easily found. Not earth shatteringly terrible in this case of course, but I would like to be informed if there's a better way to do the key.
This isn't something I've tackled before, clearly.
(btw, I don't use ds_map_secure_save as I hear it will not work when trying to load it on someone else's system. Basically, this should be a shareable file)
Keep in mind this is not for security or sensitive information, simply for ensuring the file's integrity.
Cheers!
Trying to simply find a nice way to save a file of data which can be shared without being modified. This is for a level editor shareable save file.
The main goal is a file which the contents can be freely read, but the game will know if it's been modified or incorrect.
I save a level locally as a text file using a json_encoded DS map. I will add a 'key' string which is simply defined in the game code and create an MD5 of that entire thing to put at the start in the file.
This way, when the file is saved it has the hash and the file data without the key, so people (and me) can freely look at the data (as it doesn't help me at all to just hide it with encoding) and the game will not load a modified (and by extension, incorrect) file.
[HASH of key+data] [DATA]
The only downside with this is people could find out what the key string is since it's just hardcoded into the game... and what if somehow I lost the key? Is there a smarter way to approach this? Some kind of dynamic key that isn't as obvious? I thought of basing it on the string length somehow, something like that. Or maybe I'm just being a total fool? Pretty much the only issue is the key potentially being easily found. Not earth shatteringly terrible in this case of course, but I would like to be informed if there's a better way to do the key.
This isn't something I've tackled before, clearly.
(btw, I don't use ds_map_secure_save as I hear it will not work when trying to load it on someone else's system. Basically, this should be a shareable file)
Keep in mind this is not for security or sensitive information, simply for ensuring the file's integrity.
Cheers!