Encrypted ESPL Files
The ESPL language has the ability to encrypt ESPL programming files. This allows ESPL developers to sell or distribute their programs without revealing the source code and proprietary formulas to their customers. System developers who market their ESPL programs with a monthly subscription can include expiration dates in their programs (which cause the programs to cease working on a specified shut-off date). An encrypted file cannot be edited or viewed, and the programming code cannot be altered by the end-user.
How it Works
ESPL programming files are normally saved with a file extension of .SPT. The .SPT files are text files that can be viewed and edited in the ESPL Editor window. Encrypted ESPL files are saved with a file extension of .LIB, and cannot be loaded into the ESPL Editor. An ESPL program cannot be run unless there is an .SPT file loaded into the ESPL Editor. The ability to include encrypted code in a program is accomplished by using the $Include statement (see the documentation for the $Include statement for more details). For example, assume that there is an encrypted ESPL file named MYCODE.LIB, and a normal ESPL program file named SYSTEM.SPT (shown below). The encrypted ESPL code in the MYCODE.LIB file can be inserted into the SYSTEM.SPT program by using the $Include statement.
The SYSTEM.SPT program is only 4 lines long. However, all of the programming code in the MYCODE.LIB file is internally inserted at the $Include line location when the program is RUN. The SYSTEM.SPT file is just a starter program that is used to run the system. All of the important programming code is contained in the MYCODE.LIB file. The programming code for the 'RunMySystem' procedure (called in the code above) is located in the MYCODE.LIB file. All of the encrypted code is used as if it were present in the SYSTEM.SPT program. The only difference is that the end-user of the system never sees the programming code in the MYCODE.LIB file and cannot load or edit that programming code. Note: The MYCODE.LIB file must be located in the same folder, on the hard disk, as the SYSTEM.SPT file (usually the \ENSIGN\ESPL folder).
How to Create an Encrypted File
To create an encrypted .LIB file you must first start with a normal .SPT file (that is not encrypted). Write all of your programming code in one file and save the completed program as an .SPT file (example: PROFIT1.SPT). Test your program and make sure that it runs properly. If there is a large section of code that you want to encrypt, then CUT and PASTE that code into a new .SPT file and save the file with a different name (example: PROFIT2.SPT). Then save the new file again, by selecting ESPL | Save As from the menu. Save the file as PROFIT2.LIB. There will now be a PROFIT1.SPT file, a PROFIT2.SPT file, and a PROFIT2.LIB file. The PROFIT2.LIB file will be an exact copy of the PROFIT2.SPT file, except it has been encrypted. Next, insert an $Include statement in the PROFIT1.SPT file at the location where the code was CUT out. Example:
When the PROFIT1.SPT file is loaded and run, all of the encrypted code from the PROFIT2.LIB file will be inserted at the location on the $Include statement (as if that code were still present in the PROFIT1.SPT file).
A system developer could then distribute the PROFIT1.SPT file and the PROFIT2.LIB file to his customers. The developer would keep the PROFIT2.SPT file private, and would only use it to make changes or additions to the system. If new changes and additions were made to the system, then the developer would need to distribute an updated copy of the PROFIT2.LIB to his customers. The developer would instruct his customers to save the PROFIT1.SPT and PROFIT2.LIB files to the \ENSIGN\ESPL folder, and then load the PROFIT1.SPT file into the ESPL Editor window to run the system.
Updating Encrypted Files
Each .LIB file has a companion .SPT file. In
the example above, the PROFIT2.SPT file and the PROFIT2.LIB
file are companion files that contain the same contents. The only
difference is that the PROFIT2.SPT file is a text file, and the
PROFIT2.LIB file is an encrypted duplication of the PROFIT2.SPT
file. After a .LIB file has been created, then any changes to
the .SPT file will automatically be saved in the .LIB
file. This allows the system developer to load the PROFIT2.SPT
file into the ESPL Editor and make some changes. When the changes are
saved in the PROFIT2.SPT
The .LIB files cannot be edited directly. This means that you cannot load a .LIB file into the ESPL Editor window for editing. In order to update a .LIB file, you must load its companion .SPT source file into the ESPL Editor window and then save the changes. When the changes are saved in the .SPT file, the .LIB file will also get updated and saved with the latest changes.
ESPL allows system developers to place their proprietary code in encrypted files. Encrypted .LIB files are not stand-alone executable files, and must be included into an .SPT ESPL program file by using the $Include statement. The $Include statement inserts the programming code contained in the .LIB file at the exact location of the $Include statement. Some typical uses for .LIB files include the following:
The following two programming code segments illustrate how to use the
.LIB file concept. The first program segment contains programming
code to draw
Note: The customers would only be able to see the 4 programming
lines in the HIGHLINE.SPT file. The programming code in the
LINE.LIB file would be out-of-sight and encrypted.
When developing ESPL code that will eventually be broken-out and saved in a .LIB file, try to write the complete program in one master program first. Make sure that the whole program is debugged and working fine as one program. Then CUT and PASTE the section of code that is to be encrypted into a separate file and save it as a .LIB file. Then insert an $Include statement at the point that the code was cut out of the original program.
Using a Shut-Off Date
The following sample code shows how to use a shut-off date in an encrypted file. When the shut-off date is reached, the program will no longer work. The starter file is named SYSTEM.SPT. The Encrypted programming code is saved in the HIDDEN.SPT and HIDDEN.LIB files. The program would be run on a chart by clicking the ESPL RUN 51 button.