Encrypted ESPL Files
Prior
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.
{$Include MYCODE}
begin
if ESPL=0 then RunMySystem;
end;
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:
{$Include PROFIT2}
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
file, then the changes are automatically updated, encrypted, and saved in the
companion PROFIT2.LIB file. In summary, whenever changes are made to
an .SPT file, the changes will also be made in its companion
.LIB file (if the .LIB file exists).
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:
- Hide proprietary formulas, studies, and technical analysis
- Prevent modification of and tampering with original work
- Hide the details of security authorization
- Prevent security mechanisms from being removed
- Include expiration dates in the file to cause a program to stop working
Example
The following two programming code segments illustrate how to use the
.LIB file concept. The first program segment contains programming
code to draw
a line on a chart, connecting all the HIGH prices on a chart with a white line.
This code is then saved in a file named LINE.SPT (a file named
LINE.LIB is also created and saved with the encrypted version of the
code). The second program segment is the master ESPL program which calls
the LINE.LIB statements by using the $Include statement.
This code is then saved in a file named HIGHLINE.SPT. The
HIGHLINE.SPT file and the LINE.LIB file could be distributed
to paying customers. The files should be saved in the \ENSIGN\ESPL
folder. To run the program on an active chart window, the end-user would
click ESPL RUN button 51 (ESPL=51).
{******LINE.SPT*************
Also save this code in the LINE.LIB file}
procedure DrawLine;
var
i:integer;
begin
SetUser(eWindow,eChart);
{Plot on the chart}
SetUser(eClose,True);
{Update Line at Bar Completion}
SetUser(ePlot1,True);
SetUser(eShow1,True);
for i:= 1 to BarEnd do
begin
SetUser(1,High(i),I,clWhite,7); {Connect all High
Prices with White Dotted Line}
end;
end;
{*******HIGHLINE.SPT********** Save this
code in the HIGHLINE.SPT file}
{$Include LINE.LIB}
begin
if ESPL=51 then DrawLine;
end;
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.
Developer Suggestion
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.
{***************HIDDEN.SPT*************** also saved in the
HIDDEN.LIB file}
var
ShutOffDate: string;
procedure DrawMyLines;
begin
{enter code to draw custom study lines on a chart here}
end;
procedure RunSystem;
begin
ShutOffDate := '12-31-02' ; {Enter a Shut-Off
Date}
if StringToDate(DateStr) < StringToDate(ShutOffDate) then
begin
if ESPL = 51 then DrawMyLines;
end
else
begin
writeln('Contact System Developer at 800-111-2222 to Renew
your Subscription');
writeln('Todays Date: ',LongToDate(StringToDate(DateStr)));
writeln('Expire Date: ',LongToDate(StringtoDate(ShutOffDate)));
end;
end;
{***************SYSTEM.SPT***************}
{$INCLUDE HIDDEN}
begin
RunSystem;
end;
Prior
|