Godot PCK encryption on Android and iOS
If you have shipped a Godot game, you have probably wondered how easy it is for someone to open it up. The honest answer is: very easy. Free tools like GDRE Tools take an exported game and give back the whole project, scripts and all.
Godot can encrypt the PCK, which stops that. But it needs custom export templates, and on Android and iOS there are a few extra steps that are not in one place in Godot's docs. This guide puts them together, says what encryption does not stop, and shows how ShipThis does it for you if you use it.
Gwizz's video shows the whole process for a Windows game, from getting the Godot source to exporting:
What PCK encryption is
When you export, Godot puts your game's files into a PCK (Godot's own pack format - see Exporting projects). On iOS the PCK is a file inside the app bundle. On Android, Godot stores each file separately in the APK or AAB's assets folder, with a small file that lists them. Encryption works the same way on both.
PCK encryption encrypts the files in the PCK with AES-256, using a 256-bit key you make, with an MD5 checksum for each file. The game needs the same key to read its own files, so the key has to be compiled into the game. That is why you have to compile your own export templates - the official templates cannot be used.
Godot's guide for this is Compiling with PCK encryption key. This guide follows it, with the extra steps for Android and iOS. The Android steps need Godot 4.5 or later and a Gradle build. On iOS any Godot 4 version works.
What it does and does not stop
Godot's guide says the key can be found:
Of course, the key needs to be stored in the binary, but if it's compiled, optimized and without symbols, it would take some effort to find it.
— Compiling with PCK encryption key, Godot docs
So encryption stops casual unpacking: someone opening your game in a tool like GDRE Tools and getting the project back. It will not stop a determined attacker who is willing to reverse engineer the game, because the key ships in the game, and there are public tools that search game binaries for it (see the FAQ).
Encrypted (if they match the include filters):
- scripts, scenes, resources, imported textures and audio
- the PCK's file list, if "Encrypt Index" is on
- C# code on Android, because the assemblies are stored with the game files (unless you use the NativeAOT option, which compiles them to a native library)
Not encrypted:
- the engine and the game executable
- GDExtension and plugin libraries
- platform files outside the PCK, such as the Android manifest, the Info.plist and icons
- C# code on iOS - it is compiled to native code and is not in the PCK
- save files - see the FAQ