Option encrypted in Procedures
Calling Sequence
Description
Examples
option encrypted
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.
sq := proc(x) option encrypted; x^2 end proc;
sq ≔ procxoptionencrypted;x^2end proc
The source statements can be seen prior to saving:
eval⁡sq
procxoptionencrypted;x^2end proc
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
libname≔libname,repo:
The procedure can be invoked as usual
sq⁡5
25
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
Download Help Document