compiling_with_script_encryption_key.rst 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. .. _doc_compiling_with_script_encryption_key:
  2. Compiling with PCK encryption key
  3. =================================
  4. .. highlight:: shell
  5. The export dialog gives you the option to encrypt your PCK file with an 256bit
  6. AES key, when releasing your game. This will make sure your scenes, scripts
  7. and other resources are not stored in plain text and can not easily be ripped
  8. by some script kiddie.
  9. Of course the key needs to be stored in the binary, but if it's compiled,
  10. optimized and without symbols, it would take some effort to find it.
  11. For this to work, you need to build the export templates from source,
  12. with that same key.
  13. Step by step
  14. ------------
  15. 1. Generate a 256bit AES key in HEX. You can use the aes-256-cbc variant from
  16. `this service <https://asecuritysite.com/encryption/keygen>`_.
  17. Alternatively, you can generate it yourself by using OpenSSL:
  18. ::
  19. openssl rand -hex 32 > godot.gdkey
  20. The output in ``godot.gdkey`` should be similar to:
  21. ::
  22. aeb1bc56aaf580cc31784e9c41551e9ed976ecba10d315db591e749f3f64890f
  23. You can generate the key without redirecting the output to a file, but
  24. that way you can minimize the risk of exposing the key.
  25. 2. Set this key as environment variable in the console that you will use to
  26. compile Godot, like this:
  27. .. tabs::
  28. .. code-tab:: bash Linux/macOS
  29. export SCRIPT_AES256_ENCRYPTION_KEY="your_generated_key"
  30. .. code-tab:: bat Windows (cmd)
  31. set SCRIPT_AES256_ENCRYPTION_KEY=your_generated_key
  32. .. code-tab:: bat Windows (PowerShell)
  33. $env:SCRIPT_AES256_ENCRYPTION_KEY="your_generated_key"
  34. 3. Compile Godot export templates and set them as custom export templates
  35. in the export preset options.
  36. 4. Set the encryption key in the ``Encryption`` tab of the export preset:
  37. .. image:: img/encryption_key.png
  38. 5. Add filters for the files/folders to encrypt. By default, include filters
  39. are empty and nothing will be encrypted.
  40. 6. Export the project. The game should run with the files encrypted now.
  41. Possible Errors
  42. ---------------
  43. If you get an error like below, it means the key wasn't properly included in
  44. your Godot build. Godot is encrypting PCK file during export, but can't read
  45. it at runtime.
  46. ::
  47. ERROR: open_and_parse: Condition "String::md5(md5.digest) != String::md5(md5d)" is true. Returning: ERR_FILE_CORRUPT
  48. At: core/io/file_access_encrypted.cpp:103