Compilación con cifrado de scripts por clave¶
El cuadro de diálogo de exportación te da la opción de cifrar tus scripts usando AES con una clave de 256bit. Esto hará que tus scripts no se guarden como texto plano y no sean fácilmente extraídos por un hacker de pacotilla. Por supuesto, la clave se tiene que guardar en el mismo binario, pero una vez compilado, optimizado y sin símbolos, encontrar la clave en el binario requerirá un poco de esfuerzo.
For this to work, you need to build the export templates from source, with that same key.
Paso a paso¶
Generar una clave AES de 256bit en HEX. Puedes usar la variante aes-256-cbc de este servicio.
Alternatively, you can generate it yourself by using OpenSSL:
openssl rand -hex 32 > godot.gdkey
The output in
godot.gdkey
should be similar to:aeb1bc56aaf580cc31784e9c41551e9ed976ecba10d315db591e749f3f64890f
You can generate the key without redirecting the output to a file, but that way you can minimize the risk of exposing the key.
Set this key as environment variable in the console that you will use to compile Godot, like this:
export SCRIPT_AES256_ENCRYPTION_KEY="your_generated_key"
set SCRIPT_AES256_ENCRYPTION_KEY=your_generated_key
$env:SCRIPT_AES256_ENCRYPTION_KEY="your_generated_key"
Compile Godot export templates and set them as custom export templates in the export preset options.
Guarda la clave de cifrado en la pestaña
Script
de la plantilla de exportación:Exporta el proyecto. El juego ahora funcionará con scripts cifrados.
Possible Errors¶
Si te encuentras con un error como los de abajo, significa que la clave no ha sido debidamente incluida en la compilación de Godot. Se están cifrando los scripts al exportar, pero no se pueden leer en tiempo de ejecución.
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
ERROR: load_byte_code: Condition ' err ' is true. returned: err
At: modules/gdscript/gdscript.cpp:755
ERROR: load: Condition ' err != OK ' is true. returned: RES()
At: modules/gdscript/gdscript.cpp:2135
ERROR: Failed loading resource: res://Node2D.gde
At: core/io/resource_loader.cpp:279
ERROR: poll: res://Node2D.tscn:3 - Parse Error: [ext_resource] referenced nonexistent resource at: res://Node2D.gd
At: scene/resources/scene_format_text.cpp:439
ERROR: load: Condition ' err != OK ' is true. returned: RES()
At: core/io/resource_loader.cpp:202
ERROR: Failed loading resource: res://Node2D.tscn
At: core/io/resource_loader.cpp:279
ERROR: Failed loading scene: res://Node2D.tscn
At: main/main.cpp:1727
WARNING: cleanup: ObjectDB Instances still exist!
At: core/object.cpp:2081
ERROR: clear: Resources Still in use at Exit!
At: core/resource.cpp:425