The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes
The docs here are a bit to short and not broad enough to be of help. Here they just use the storevar function in File, but what if I want to encrypt a ConfigFile and use setvalue()?. Tried to apply the same technique directly, but it doesn't seem to work:

var save_path = "res://SaveFile.cfg"
var config =
var load_respone = config.load(save_path)
var file =

func saveValue(section, key, value):
    file.open_encrypted_with_pass(save_path, File.WRITE, "mypass")
    config.set_value(section, key, value)

func loadValue(section, key):
    file.open_encrypted_with_pass(save_path, File.READ, "mypass")
    return config.get_value(section, key, 0)
in Engine by (75 points)

1 Answer

+1 vote

You don't have to use the File class along with ConfigFile. Try this:

var password = OS.get_unique_id() # works only on this computer
var save_path = "res://SaveFile.cfg"
var config =

# skip this load if the file doesn't exist yet
var error = config.load_encrypted_pass(save_path, password)

config.set_value(section, key, value)
config.save_encrypted_pass(save_path, password)"res://SaveFile_unencrypted.cfg", password) # for testing
by (34 points)

Ahh I see the problem. I thought ConfigFile didn't have the save or load encrypted functions, because when I want to check the docs I usually just google it and the 3.1 docs apparently shows up when you do that. So I was looking at an outdated docs where ConfigFile seemingly didn't have those functions. Well thanks I can hopefully get it working now.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.