Skip to content

Export: Script Encryption Key field produces silently broken exports without custom-compiled templates — editor should handle key injection automatically #119564

Description

@ymmtest10

Tested versions

Godot version

4.6-stable

System information

Windows / Linux (reproducible on both)

Issue description

The Editor Settings panel exposes a "Script Encryption Key" field under
Export. A developer who sets this key and exports a project with
encrypt_pck=true in their export preset receives no errors or warnings.
The export appears to succeed.

At runtime on the target machine, the game immediately crashes with:
"could not load project data"

The cause is that official Godot export templates are compiled with an
empty key. The encrypted PCK cannot be decrypted at runtime because the
key the developer entered was never embedded in the template executable.

This is a silent failure of a first-class editor feature.

Expected behavior

When a developer sets a Script Encryption Key and exports, the resulting
executable should work. The editor already knows both the key and the
template binary — it has everything it needs to produce a working export.

The recommended fix is key injection at export time:

  • Compile official templates with a known fixed-size placeholder at a
    documented offset
  • At export time, when a Script Encryption Key is set, patch the placeholder
    in the template binary before writing the final executable
  • This requires no user-side compilation, no SCons, no MinGW, and no
    additional toolchain dependencies

Current workaround

The developer must compile a custom Godot export template from source
with the key baked in via SCRIPT_ENCRYPTION_KEY=... passed to SCons.
This requires a full C++ build toolchain, 6 GB of disk space, and
30-60 minutes of compile time — none of which is mentioned in the editor.

Minimal reproduction

  1. Open any Godot 4.6 project
  2. Set Editor Settings → Export → Script Encryption Key to any valid
    64-character hex string
  3. Set encrypt_pck=true in any export preset
  4. Export for Windows using the official export template
  5. Run the exported .exe
  6. Observe: crash with "could not load project data"

System information

Godot v4.6.stable - Fedora Linux 43 (Cinnamon) on X11 - X11 display driver, Multi-window, 2 monitors - OpenGL 3 (Compatibility) - Mesa Intel(R) UHD Graphics (CML GT2) - Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz (12 threads) - 30.96 GiB memory

Issue description

The "Script Encryption Key" field in Editor → Editor Settings → Export
produces silently broken exports when used with official export templates.

When a developer:

  1. Sets a 64-character hex key in Editor Settings → Export → Script Encryption Key
  2. Enables encrypt_pck=true in an export preset
  3. Exports using the official Godot export template

The export completes with no error and no warning. The resulting executable
crashes immediately at runtime with:

Couldn't load project data at path ".". Is the .pck file missing?

The root cause is that official export templates are compiled with an empty
encryption key. The PCK is encrypted with the developer's key at export time,
but the template binary has no key embedded and cannot decrypt it at runtime.

The editor gives no indication that this workflow requires compiling a custom
export template from source — a process requiring SCons, a C++ cross-compiler
toolchain, ~6 GB of disk space, and 30–60 minutes of compile time.

Expected behavior: when a Script Encryption Key is set, the export should
either produce a working executable, or display a clear error explaining that
a custom export template compiled with the same key is required. Silent success
followed by a runtime crash is not acceptable behavior for an advertised
first-class editor feature.

A technically straightforward fix would be for the editor to patch the key
into the official template binary at export time, eliminating the need for
custom compilation entirely.

Steps to reproduce

  1. Open any Godot 4.6 project.

  2. Go to Editor → Editor Settings → Export → Script Encryption Key.
    Enter any valid 64-character hex string, for example:
    a3f1b2c4d5e6f7089a1b2c3d4e5f60718293a4b5c6d7e8f90a1b2c3d4e5f6071

  3. Go to Project → Export. Add a Windows Desktop export preset.

  4. In the preset, go to the Encryption tab.
    Enable "Encrypt Exported PCK".
    Confirm the encryption key field shows the key entered in step 2.

  5. Click "Export Project". The export completes with no errors or warnings.

  6. Run the exported .exe on Windows.

Result: the game crashes immediately with:
Couldn't load project data at path ".". Is the .pck file missing?

Expected: the game launches normally with PCK contents encrypted.

Note: the issue does not require a specific project. Any project reproduces
it, including a new empty project, as long as the official Godot export
template is used (i.e. no custom-compiled template has been installed).

Minimal reproduction project (MRP)

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions