2
0

compiling_with_script_encryption_key.rst 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. .. _doc_compiling_with_script_encryption_key:
  2. Compiling with script encryption key
  3. ====================================
  4. .. highlight:: shell
  5. The export dialog gives you the option to encrypt your scripts with an 256bit
  6. AES key, when releasing your game. This will make sure your scripts are not
  7. stored in plain text and can not easily be ripped by some script kiddie.
  8. Of course the key needs to be stored in the binary, but if it's compiled,
  9. optimized and without symbols, it would take some effort to find it.
  10. For this to work, you need to build the export templates from source,
  11. with that same key.
  12. Step by step (Linux)
  13. --------------------
  14. 1. Generate a 256bit AES key in HEX. You can use the aes-256-cbc variant from
  15. `this service <https://asecuritysite.com/encryption/keygen>`_.
  16. Alternatively, you can generate it yourself by using OpenSSL:
  17. ::
  18. openssl enc -aes-256-cbc -k secret -P -md sha1 > godot.gdkey
  19. This should output the following to ``godot.gdkey`` file:
  20. ::
  21. salt=5786FE8B91CA048A
  22. key=D2F90FCC4FCA64B8990F916EF5A73230C1841601D1EA06B2380EC0F530E4EF85
  23. iv =047C353AEC9E6C211515E3341BF9C61B
  24. You can generate the key without redirecting the output to a file, but
  25. that way you can minimize the risk of exposing the key.
  26. 2. Set this key as environment variable in the console that you will use to
  27. compile Godot, like this:
  28. ::
  29. export SCRIPT_AES256_ENCRYPTION_KEY="your_generated_key"
  30. 3. Compile Godot export templates and set them as custom export templates
  31. in the export preset options.
  32. 4. Set the encryption key in the ``Script`` tab of the export preset:
  33. .. image:: img/script_encryption_key.png
  34. 5. Export the project. The game should run with encrypted scripts now.
  35. Possible Errors
  36. ---------------
  37. If you get an error like below, it means the key wasn't properly included in
  38. your Godot build. Godot is encrypting the scripts during export, but can't read
  39. them at runtime.
  40. ::
  41. ERROR: open_and_parse: Condition ' String::md5(md5.digest) != String::md5(md5d) ' is true. returned: ERR_FILE_CORRUPT
  42. At: core/io/file_access_encrypted.cpp:103
  43. ERROR: load_byte_code: Condition ' err ' is true. returned: err
  44. At: modules/gdscript/gdscript.cpp:755
  45. ERROR: load: Condition ' err != OK ' is true. returned: RES()
  46. At: modules/gdscript/gdscript.cpp:2135
  47. ERROR: Failed loading resource: res://Node2D.gde
  48. At: core/io/resource_loader.cpp:279
  49. ERROR: poll: res://Node2D.tscn:3 - Parse Error: [ext_resource] referenced nonexistent resource at: res://Node2D.gd
  50. At: scene/resources/scene_format_text.cpp:439
  51. ERROR: load: Condition ' err != OK ' is true. returned: RES()
  52. At: core/io/resource_loader.cpp:202
  53. ERROR: Failed loading resource: res://Node2D.tscn
  54. At: core/io/resource_loader.cpp:279
  55. ERROR: Failed loading scene: res://Node2D.tscn
  56. At: main/main.cpp:1727
  57. WARNING: cleanup: ObjectDB Instances still exist!
  58. At: core/object.cpp:2081
  59. ERROR: clear: Resources Still in use at Exit!
  60. At: core/resource.cpp:425