godot
godot copied to clipboard
File.open_encrypted_with_pass() returns ERR_FILE_UNRECOGNIZED
Godot version: 3.1.1.stable-official
OS/device including version: Windows 7
Issue description:
If you try to read or write a file using File.open_encrypted_with_pass() it returns ERR_FILE_UNRECOGNIZED and doesn't say much more.
Windows cmd displays:
ERROR: open_and_parse: Condition ` magic != 0x43454447 ` is true. returned: ERR_FILE_UNRECOGNIZED
At: core/io/file_access_encrypted.cpp:65
Steps to reproduce:
var file : File = File.new()
var open_result = file.open_encrypted_with_pass("user://user.json", File.WRITE_READ, OS.get_unique_id())
print("Open result ", open_result)
I try your reproduce in my laptop is window10, and it have another problem, So I think may could change the way to read and write the file, for example:
func save(content):
var file = File.new()
file.open("user://save_game.dat", File.WRITE)
file.store_string(content)
file.close()
Here is the link I found,I hope this will help you https://docs.godotengine.org/en/3.1/classes/class_file.html
Still valid in 3.2.3
Looks like open_encrypted_with_pass() doesn't support WRITE_READ mode, not sure if it's intended.
Still happens in 4.0-beta13 with the new FileAccess API.
Still happens in versions 4.2.1 and 4.2.2 and 4.3-beta3
The file is supposed to be created if I do the following:
extends Node2D
func _ready():
var _file_path := "user://my_file.save"
var file = FileAccess.open_encrypted_with_pass(
_file_path,
FileAccess.WRITE_READ,
"123456"
)
var _error = FileAccess.get_open_error()
var content = file.get_var()
file.close()
I am using: Godot Engine v4.2.1.stable.arch_linux - https://godotengine.org OpenGL API 4.6 (Core Profile) Mesa 23.3.3-manjaro1.1 - Compatibility - Using Device: Intel - Mesa Intel(R) UHD Graphics (CML GT2)
Minimal Example: ERR_FILE_UNRECOGNIZED.zip