Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do you make sure a txt file with a dictionary in it can't be edited?

So I am trying to add save files to my text-adventure game that can’t be edited by the user. This is so that they can’t cheat by editing the dictionary inside of it. So far all I’ve done is a few algorithms that can be easily bypassed if you connected the dots. Basically it’s this.

import sys,os,ast
dictionary = {...}
save_dictionary = {...}
def save():
    filehandler = open("dictionary.txt", "a")
    data = str(dictionary)
    filehandler.write(data)
    filehandler.close()

def savecode():
    savecode = dictionary.values()
    total = sum(savecode)
    save_dictionary['savecodes'] = round(math formulas)
    filehandler = open("save_dictionary.txt", "a")
    data = str(save_dictionary)
    filehandler.write(data)
    filehandler.close()

def load():
    with open('dictionary.txt') as f:
        data = f.read()
        save = ast.literal_eval(data)
        f.close()

But the problem I’m facing is that it is easily by-passible if you just add an amount and equally subtract an amount, which would make the sum the same, making everything work the same. I did make it so that anytime the game itself detects any changes it immediately deletes all save files and makes you start over.

So is the solution making the files unable to be accessed at all? Or is it that the python file will detect the time it was created? I have no idea. It could be another option.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can’t hide files from the super user. They bought their computer and they reserve the right to read and edit whatever files they please. And no program will ever have higher permissions than the administrator.

Your best bet is to encrypt the data inside the file. So that if the user tries to edit, the program won’t function properly.

A question that might be more relevant:
https://gamedev.stackexchange.com/questions/48629/how-do-i-prevent-memory-modification-cheats

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading