how to encrypted save file?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By potatobanana

how to encrypted ResourceSaver save file?

var new_save = save_data.new()
new_save.save_1 = global_object.player_current_data 
ResourceSaver.save("res://save_1.tres", new_save)

this how i do with json

var file = File.new()
var error =file.open_encrypted_with_pass(save_path2,File.WRITE,"123")
if error == OK:
	file.store_line(to_json(new_data))
	file.close()
:bust_in_silhouette: Reply From: Wakatta
var new_save = save_data.new()
new_save.save_1 = global_object.player_current_data 

var file = File.new()
var error =file.open_encrypted_with_pass("res://save_1.tres", File.WRITE, "123")
if error == OK:
    file.store_var(new_save, true)
    file.close()

use file.get_var(true) to load whole sceneTrees can be saved and loaded this way

Wakatta | 2021-02-27 21:41

How can we load and access variables from this file and save them?

OiKeTTLe | 2022-06-07 09:52

Recommend using var2dict() and dict2var() in that case and know that regardless of the method, reference pointers will be lost when saved.

Another method would be to use _get_property_list after creating a reference for the loaded data or simply do

var save_data = file.get_var()
save_data.my_variable

Wakatta | 2022-06-07 11:45