 encrypted - Maple Help

Option encrypted in Procedures 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;
 ${\mathrm{sq}}{≔}{\mathbf{proc}}\left({x}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{option}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{encrypted}}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{x}{^}{2}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (1)

The source statements can be seen prior to saving:

 > $\mathrm{eval}\left(\mathrm{sq}\right)$
 ${\mathbf{proc}}\left({x}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{option}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{encrypted}}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{x}{^}{2}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (2)

Save the procedure named sq:

 > $\mathrm{repo}≔\mathrm{cat}\left(\mathrm{FileTools}:-\mathrm{TemporaryDirectory}\left(\right),"/mysq.mla"\right):$
 > $\mathrm{savelib}\left(\mathrm{sq},\mathrm{repo}\right)$

Now restart your session to clear the current state.

 > $\mathrm{restart}$

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

 > $\mathrm{repo}≔\mathrm{cat}\left(\mathrm{FileTools}:-\mathrm{TemporaryDirectory}\left(\right),"/mysq.mla"\right):$
 > $\mathrm{libname}≔\mathrm{libname},\mathrm{repo}:$

The procedure can be invoked as usual

 > $\mathrm{sq}\left(5\right)$
 ${25}$ (3)

But viewing and debugging commands are now disabled:

 > $\mathrm{showstat}\left(\mathrm{sq}\right)$