Install Steam
login
|
language
简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
日本語 (Japanese)
한국어 (Korean)
ไทย (Thai)
Български (Bulgarian)
Čeština (Czech)
Dansk (Danish)
Deutsch (German)
Español - España (Spanish - Spain)
Español - Latinoamérica (Spanish - Latin America)
Ελληνικά (Greek)
Français (French)
Italiano (Italian)
Bahasa Indonesia (Indonesian)
Magyar (Hungarian)
Nederlands (Dutch)
Norsk (Norwegian)
Polski (Polish)
Português (Portuguese - Portugal)
Português - Brasil (Portuguese - Brazil)
Română (Romanian)
Русский (Russian)
Suomi (Finnish)
Svenska (Swedish)
Türkçe (Turkish)
Tiếng Việt (Vietnamese)
Українська (Ukrainian)
Report a translation problem
https://docs.godotengine.org/en/stable/classes/class_configfile.html
There is an example there of using save():
This saves a file in INI-style, which is human readable. Anyone can open the file in a text editor and edit it. It's very common, I'm sure you have played some games where you can edit the ini file to change some settings.
save_encrypted() is the same, except the file is encrypted so if you open it in a text editor without decrypting it will look like gibberish. You can use this to "protect" your game settings, savegames or whatever from being edited outside the game.
You need to give it a key to encrypt/decrypt with. This key is of a type PoolByteArray (not packedbytearray).
https://docs.godotengine.org/en/stable/classes/class_poolbytearray.html
PoolByteArray is just a special array optimised for storing bytes. In other words it's an array of 1-byte numbers (0 to 255) instead of any mix of data types like a normal array.
Instead of manually constructing a PoolByteArray like this, number by number, you can use a string (like a password/passphrase, a unique ID for the character/player, or any other info) and hash it using one of the cryptographic functions. For example str.sha256_buffer() will return the SHA-256 hash of your string as a PoolByteArray. You can find other examples on the string class docs[docs.godotengine.org] or other classes.
You can see what the key looks like by converting it back to a string of hex numbers. These 2 should be identical:
Now the settings.cfg file can't be easily edited by the user unless they know the key (or the password and the function used to hash it), and use it to decrypt the file.