This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

Hi, I used to create two files for every saved game in 3.x. One is my save data, which is encrypted by a simple string password. It is created by save_encrypted_pass(path, password) from a ConfigFile. The other is a screenshot.

Now in Godot 4 beta, I'm now able to use ZIPPacker to pack the screenshot and save data together as one single zip file. And ZIPPacker.write_file only supports PackedByteArray. I use config_file.encode_to_text().to_utf_buffer() to convert it to PackedByteArray. But how do I encrypt PackedByteArray?

I know CryptoKey. However, it seems to support only RSA encryption, not simple a string like save_encrypted_pass does.

I could save it to disk then use FileAccess.open_encrypted_with_pass(path, FileAccess.WRITE, password), then load it as PackedByteArray. But I don't want to do unnecessary IOs.

Godot version 4.0.beta17
in Engine by (332 points)

1 Answer

0 votes
Best answer

OK, I figured it out. Use AESContext.
But it's so deeply hidden?
Also, save_encrypted_pass uses AES256, but it's not mentioned anywhere in docs.
Might need to submit an issue about this.

by (332 points)
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.