Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
Compiling with PCK encryption key
The export dialog gives you the option to encrypt your PCK file with a 256-bit AES key when releasing your project. This will make sure your scenes, scripts and other resources are not stored in plain text and can not easily be ripped by some script kiddie.
Bien sûr, la clé doit être stockée dans le binaire, mais si elle est compilée, optimisée et sans symboles, il faudrait un certain effort pour la trouver.
Pour que cela fonctionne, vous devez créer les modèles d'exportation à partir des sources, avec cette même clé.
Avertissement
Cela ne fonctionnera pas si vous utilisez des modèles d'export précompilés, officiels. Il est absolument nécessaire de compiler vos propres modèles d'export pour utiliser le chiffrement PCK.
Avertissement
By default, Android exports store assets directly in the APK file and aren't affected by PCK encryption. To use PCK encryption on Android, enable APK expansion in the export options.
Pas à pas
Generate a 256-bit AES key in hexadecimal format. You can use the aes-256-cbc variant from this service.
Alternatively, you can generate it yourself using OpenSSL command-line tools:
openssl rand -hex 32 > godot.gdkey
La sortie dans
godot.gdkey
devrait être similaire à :# NOTE: Do not use the key below! Generate your own key instead. aeb1bc56aaf580cc31784e9c41551e9ed976ecba10d315db591e749f3f64890f
Vous pouvez générer la clé sans rediriger la sortie vers un fichier, mais de cette façon, vous pouvez minimiser le risque d'exposer la clé.
Définissez cette clé comme variable d'environnement dans la console que vous utiliserez pour compiler Godot, comme ceci :
export SCRIPT_AES256_ENCRYPTION_KEY="your_generated_key"
set SCRIPT_AES256_ENCRYPTION_KEY=your_generated_key
$env:SCRIPT_AES256_ENCRYPTION_KEY="your_generated_key"
Compilez les modèles d'exportation Godot et définissez-les en tant que modèles d'exportation personnalisés dans les options d'exportation prédéfinies.
Set the encryption key in the Encryption tab of the export preset:
Add filters for the files/folders to encrypt. By default, include filters are empty and nothing will be encrypted.
Export the project. The project should run with the files encrypted now.
Dépannage
If you get an error like below, it means the key wasn't properly included in your Godot build. Godot is encrypting PCK file during export, but can't read it at runtime.
ERROR: open_and_parse: Condition "String::md5(md5.digest) != String::md5(md5d)" is true. Returning: ERR_FILE_CORRUPT
At: core/io/file_access_encrypted.cpp:103