Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.5b

Application v 5.24b

  

 

Chapter TwoLanguage Overview (continued)

ScriptCrunch Function

Overview

The ScriptCrunch function preprocesses a script and crunches the result. In addition, the script can be signed and encrypted.

Syntax/Parameters

Syntax

int = ScriptCrunch ( string source, string destination, [dword options] );

Parameters

source

A string containing a qualified filename for the script to crunch.

destination

A string containing a qualified filename to write the crunched script. The script must have full read/write access to the file. If the string is empty, the source filename is used to write back the crunched data.

options

An optional dword containing option flags for the crunch process. If omitted, the default is to encrypt the script, SCRIPT_CRUNCH_ENCRYPT.

Return Value

Returns an int as ERROR_NONE or a formatted error code on failure. The error code can have additional bits set to indicate an issue for the source or destination file or signing issues. If the script fails to preprocess, an ERROR_SYNTAX will be returned. Use the GetLastErrorLog function to get a log of errors and locations.

Remarks

By crunching a script, a programmer can either significantly reduce the human code readability and code size or make it completely unreadable. This is similar to code obfuscation in other programming languages.

The ScriptCrunch function undertakes a number of steps to crunch a script. Depending on the options selected, the following is performed:

–  Source code is preprocessed.

–  Combine code is crunched.

–  The code is optionally signed.

–  The code is optionally compressed and encrypted.

The act of “crunching code” removes all comments and unnecessary spaces, tabs and other superfluous information from the code. Any text included such as resources and other information is embedded during the crunch process.

If the code is encrypted, it can only be executed. The resulting file is not editable.

The option codes are as follows:

  SDK Definition   Code/Bits   Description
  SCRIPT_CRUNCH_WANT_LOG   0x00000001   Return Pointer to Log (caller owns)
  SCRIPT_CRUNCH_SIGN   0x00000002   Sign Code
  SCRIPT_CRUNCH_ENCRYPT   0x00000004   Encrypt Code
  SCRIPT_CRUNCH_DEBUG_INFO   0x00000008   Add Debug Info (reserved for future use)

 

Programmers should not crunch source scripts and return the crunched data to the source file. The file will be overwritten.

When the sign code option is enabled (using the SCRIPT_CRUNCH_SIGN bit), a signature is added using an available code signing certificate. See ScriptSign. If the source script is sign, the certification information and signature will be stripped during the processing process. (Since a signature is stored as comments, they are removed as part of the crunch process. Therefore, any signature from the source is essentially ignored,)

Related Functions

Platform Support

Go13, Go16, GoFiler Complete, GoFiler Corporate, GoFiler, GoFiler Lite, GoXBRL

Legato IDE, Legato Basic