godot icon indicating copy to clipboard operation
godot copied to clipboard

File.open_encrypted_with_pass() returns ERR_FILE_UNRECOGNIZED

Open vicguedez opened this issue 6 years ago • 4 comments
trafficstars

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)

vicguedez avatar Oct 16 '19 23:10 vicguedez

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

fsy98 avatar Oct 22 '19 19:10 fsy98

Still valid in 3.2.3 Looks like open_encrypted_with_pass() doesn't support WRITE_READ mode, not sure if it's intended.

KoBeWi avatar Oct 25 '20 23:10 KoBeWi

Still happens in 4.0-beta13 with the new FileAccess API.

venilark avatar Jan 19 '23 08:01 venilark

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()

imagen

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

MatiasVME avatar Feb 08 '24 21:02 MatiasVME