Skip to content

ENCRYPT

Encrypt Program File

This directive encrypts or decrypts a program file. Encryption prohibits a programmer from LISTing any program line number or labels past line 00100, but does not impair program operation or usability.

ENCRYPT program-name1, program-name2 [,PWD=passwd]
[,ERR=line-ref|,ERC=error-code]
program-name1
is any string of 8 characters or fewer which specifies the name of an existing program to be encrypted or decrypted.
program-name2
is any string of 8 characters or fewer which specifies the name for a new program which contains the result of the encrypt or decrypt operation.
passwd
is any string in the range of 4 to 8 characters in length.
line-ref
is the program line number or label to branch to if this directive produces an error.
error-code
is a programmer-defined error code. Valid values are positive or negative whole numbers.

ENCRYPTing a program without specifying the PWD= clause or specifying a password whose value is null results in the use of a random string in the ENCRYPTion algorithm and the ENCRYPTed program can never be decrypted.

ENCRYPTing program-name1 as program-name2 does not remove program-name1.

If an attempt is made to ENCRYPT an already ENCRYPTed program, an ERR=18 results, unless the PWD= clause specifies the correct password for the already ENCRYPTed program. In this case, the ENCRYPT process is reversed and the resultant program is decrypted.

If all program statements are numbered below 00100, Thoroughbred Basic generates an ERR=18 because all program lines are readable.

The program-name2 parameter can be:

  • An existing program, which is overwritten.
  • The same as program-name1, which overwrites program-name1.
  • A new program name, which is created in the same logical disk directory as the source program.

The display and modification of an ENCRYPTed program is restricted for the following directives: LIST, EDIT, PGM, MERGE, SAVE, and PSAVE. An attempt to use these directives on an encrypted program results in an ERR=18 (Secure File Access); however, the LIST directive can still operate on program lines 1 through 99. ENCRYPTed program security starts at program line 100. These restrictions can be temporarily suspended when a reversible encrypted program is loaded using the PWD= option.

The PSAVE command can also encrypt a program.

PSAVE and LOAD directives

From the Thoroughbred Basic Language Reference, Volume I: A–E, version 8.9.1. Open this page in the PDF