Option encrypted in Procedures - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Procedures and Functions : options : encrypted

Option encrypted in Procedures

 

Calling Sequence

Description

Examples

Calling Sequence

option encrypted

Description

• 

A procedure with option encrypted that has been loaded from a repository will have its source obfuscated so that it cannot be viewed or debugged.  This is useful when you want to share executable code, but do not want the user to see the source implementation.

• 

The first step in creating an encrypted procedure is to add encrypted to the option sequence of the procedure.

f := proc(x) option encrypted; x^2; end proc;

  

At this point the procedure is not yet encrypted.  It must be saved in a repository first.  Use the savelib command to save the given procedure.  In a subsequent session, if the saved repository has been added to libname, and f is loaded from that repository, then the source code of f can not be viewed.

Examples

sq := proc(x) option encrypted; x^2 end proc;

sq:=procxoptionencrypted;x^2end proc

(1)

The source statements can be seen prior to saving:

eval(sq);

procxoptionencrypted;x^2end proc

(2)

Save the procedure named sq:

repo := cat(FileTools:-TemporaryDirectory(),"/mysq.mla"):

savelib(sq,repo);

Now restart your session to clear the current state.

restart;

Add your saved repository to libname so you can access the procedure sq

repo := cat(FileTools:-TemporaryDirectory(),"/mysq.mla"):

libname := libname, repo:

The procedure can be invoked as usual

sq(5);

25

(3)

But viewing and debugging commands are now disabled:

showstat(sq);

Error, (in showstat) cannot debug encrypted procedures

See Also

libname

MapleCloud

Procedure options

Procedures

repository