compiling_with_script_encryption_key.rst 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 enc -aes-256-cbc -k secret -P -md sha1 > godot.gdkey
  20. This should output the following to ``godot.gdkey`` file:
  21. ::
  22. salt=5786FE8B91CA048A
  23. key=D2F90FCC4FCA64B8990F916EF5A73230C1841601D1EA06B2380EC0F530E4EF85
  24. iv =047C353AEC9E6C211515E3341BF9C61B
  25. You can generate the key without redirecting the output to a file, but
  26. that way you can minimize the risk of exposing the key.
  27. 2. Set this key as environment variable in the console that you will use to
  28. compile Godot, like this:
  29. .. tabs::
  30. .. code-tab:: bash Linux/macOS
  31. export SCRIPT_AES256_ENCRYPTION_KEY="your_generated_key"
  32. .. code-tab:: bat Windows (cmd)
  33. set SCRIPT_AES256_ENCRYPTION_KEY=your_generated_key
  34. .. code-tab:: bat Windows (PowerShell)
  35. $env:SCRIPT_AES256_ENCRYPTION_KEY="your_generated_key"
  36. 3. Compile Godot export templates and set them as custom export templates
  37. in the export preset options.
  38. 4. Set the encryption key in the ``Encryption`` tab of the export preset:
  39. .. image:: img/encryption_key.png
  40. 5. Add filters for the files/folders to encrypt. By default, include filters
  41. are empty and nothing will be encrypted.
  42. 6. Export the project. The game should run with the files encrypted now.
  43. Possible Errors
  44. ---------------
  45. If you get an error like below, it means the key wasn't properly included in
  46. your Godot build. Godot is encrypting PCK file during export, but can't read
  47. it at runtime.
  48. ::
  49. ERROR: open_and_parse: Condition "String::md5(md5.digest) != String::md5(md5d)" is true. Returning: ERR_FILE_CORRUPT
  50. At: core/io/file_access_encrypted.cpp:103