Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | StarFox |
Sup.
In my project i have some data contained in the json file. I don’t want to let player can read it. So i need to encrypt the file, right? Right! It’s done with plugin for notepad++ NppCrypt. In godot i try to use file’s function “open_encrypted_with_pass”. And what you gonna think? It doesn’t work…
I do like that:
func _ready() -> void:
var file : File = File.new();
var t = file.open_encrypted_with_pass("res://json/myjsonfile.json", file.READ, "secret");
print(t) # And yeah, in my case it prints 7... it's try to abuse me or what?
var json = file.get_as_text();
pages = JSON.parse(json).result; #pages is Dictionary
file.close();
Errors in tab “Errors” =):
-
E 0:00:01.185 get_as_text: File must be opened before use.
<C++ Error> Condition “!f” is true. Returned: String()
<C++ Source> core/bind/core_bind.cpp:2087 @ get_as_text()
Main.gd:16 @ _ready() -
E 0:00:01.195 parse: Error parsing JSON at line 0:
<C++ Source> core/bind/core_bind.cpp:3284 @ parse()
Main.gd:17 @ _ready()
Debuger print:
Trying to assign Nill to Dictionary (in short)