VDS Renaissance 的界面提供多种语言。官方文档以英语维护,以确保提供统一、一致且始终最新的参考。
Protecting your compiled programs
[VDS7] When you compile a script, the script itself travels inside the executable file. This page describes what Visual DialogScript does to protect it, the optional RunKey mode for programs that contain valuable know-how, and what these protections can and cannot do.
What is done automatically
There is nothing to configure for this first level. In every executable built by Visual DialogScript 7 — Windows 32-bit or 64-bit, Linux, standard or integrated — the compiled script is:
- encrypted (AES-256), so it cannot be read by opening the file in an editor;
- sealed and signed: the program checks its script when it starts. If the script part of the file has been altered, the program displays an error message and does not start.
This applies to compiled programs only. Running a script from the development environment (Run, Trace, the debugger) is not affected.
The signature is made with the license of the computer that built the program, and the executable carries an identifier of that license. The identifier is an opaque value and contains no personal data. See Licensing Visual DialogScript.
The RunKey option
By default a compiled program contains everything it needs to run: that is what makes it a single file that works anywhere. The consequence is that the means of decrypting the script are, necessarily, somewhere in the file.
With the RunKey project option, the script is encrypted with a pass phrase that is not stored in the executable. The program can then run only where the pass phrase is supplied.
Setting it
There is no field for this option in the Project Manager. Close the project, open its .dsp file in a text editor, and add a RunKey line to the [Compiler] section:
[Compiler]
RunKey=a secret phrase in plain ASCII
Then compile as usual. The Compiler panel confirms that the executable requires a run key.
The pass phrase may contain printable ASCII characters only — unaccented letters, digits, spaces and common punctuation. If it contains any other character (an accented letter, for example) the compiler reports an error and no executable is produced. Leading and trailing spaces are ignored.
Supplying the pass phrase at run time
When the program starts, it looks for the pass phrase in two places, in this order:
- the environment variable
VDS_RUNKEY; - the first line of a text file with the name of the executable and the extension
.vdskey, placed in the same folder —myprog.vdskeyformyprog.exe.
If the pass phrase is missing or wrong, the program displays an error message and does not start.
For example, to start a protected program from a Windows command prompt:
set VDS_RUNKEY=a secret phrase in plain ASCII
myprog.exe
RunKey works the same way for Windows and Linux programs.
When to use it
Use RunKey when the script contains know-how or data that must not be recoverable from the file alone. You can then distribute the executable freely and give the pass phrase only to the people who are entitled to run it.
Bear in mind that:
- a
.vdskeyfile sitting next to the executable can be read by anyone who can read that folder. It is convenient, but it only protects the program while the two files are kept apart; - anyone who has both the executable and the pass phrase can run the program;
- if you lose the pass phrase, the executable cannot be run. Keep the
.dspfile — or the phrase — in a safe place and simply recompile if needed.
Signing your executables (Authenticode)
Encryption protects the script; it does not tell Windows who published the program. For that, sign your executables with an Authenticode certificate: see Code signing. Signing lets Windows and your users verify that the file really comes from you and has not been modified since.
Anything that rewrites the executable must be done before it is signed — for instance changing its icon with FILE SETICON.
What these protections do not do
No software protection is absolute, and this one is no exception.
- In the default mode the executable is self-contained, so a determined specialist with the right tools can, with effort, recover or replace the script. The automatic protection stops casual inspection and simple tampering; it is not a guarantee against an expert.
- RunKey is the strongest mode, because the pass phrase is not in the file. Its strength is that of the pass phrase and of the way you distribute it.
- None of this protects information once the program is running, nor files the program writes.
As a rule, do not put secrets that would be costly to lose — passwords, API keys, private signing seeds — in a script, even a compiled one. Read them at run time from the environment, from a file, or from the user. The AI support, for example, never requires a key in the script. To verify that data such as a license file really comes from you, ship only a public key in the program and use @VERIFY.