Encrypted Procedures - Maple Help

Home : Support : Online Help : System : Information : Updates : Maple 2018 : Encrypted Procedures

 Encrypted Procedures

Maple 2018 lets you encrypt procedures. An encrypted procedure acts and behaves like any normal procedure in Maple, but it can not be viewed or debugged. This provides a way for professional users to share executable procedures while protecting their IP.

The following defines a procedure that implements a block game as described at "http://rosettacode.org/wiki/ABC_Problem#Maple". The procedure is then saved into a repository file called "abc.mla".

After executing the code above we can call the canSpell procedure to test what words can be spelled with the given blocks.

$\mathrm{canSpell}\left("box"\right);$

 ${\mathrm{true}}$ (1)

$\mathrm{canSpell}\left("xoxox"\right);$

 ${\mathrm{false}}$ (2)

Normally the statements of a procedure can be seen via commands such as showstat and eval in Maple. This is true for this procedure too because it was just defined. Note: option encrypted only takes full effect when the procedure is loaded from a library, not when it was just entered from source.

$\mathrm{eval}\left(\mathrm{canSpell}\right);$

 ${\mathbf{proc}}\left({w}\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}}{\mathbf{local}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{blocks}}{,}{i}{,}{j}{,}{\mathrm{word}}{,}{\mathrm{found}}{,}{N}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{blocks}}{≔}{\mathrm{Array}}{}\left(\left[\left\{{"B"}{,}{"O"}\right\}{,}\left\{{"K"}{,}{"X"}\right\}{,}\left\{{"D"}{,}{"Q"}\right\}{,}\left\{{"C"}{,}{"P"}\right\}{,}\left\{{"A"}{,}{"N"}\right\}{,}\left\{{"J"}{,}{"W"}\right\}{,}\left\{{"H"}{,}{"U"}\right\}{,}\left\{{"I"}{,}{"V"}\right\}{,}\left\{{"A"}{,}{"N"}\right\}{,}\left\{{"B"}{,}{"O"}\right\}{,}\left\{{"G"}{,}{"T"}\right\}{,}\left\{{"E"}{,}{"R"}\right\}{,}\left\{{"G"}{,}{"T"}\right\}{,}\left\{{"D"}{,}{"Q"}\right\}{,}\left\{{"F"}{,}{"S"}\right\}{,}\left\{{"E"}{,}{"R"}\right\}{,}\left\{{"F"}{,}{"S"}\right\}{,}\left\{{"L"}{,}{"Y"}\right\}{,}\left\{{"C"}{,}{"P"}\right\}{,}\left\{{"M"}{,}{"Z"}\right\}\right]\right){;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{word}}{≔}{\mathrm{StringTools}}{:-}{\mathrm{UpperCase}}{}\left({\mathrm{convert}}{}\left({w}{,}{\mathrm{string}}\right)\right){;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{N}{≔}{\mathrm{numelems}}{}\left({\mathrm{blocks}}\right){;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{for}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{i}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{to}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{length}}{}\left({\mathrm{word}}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{do}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{found}}{≔}{\mathrm{false}}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{for}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{j}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{to}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{N}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{do}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{if}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{word}}{[}{i}{]}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{in}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{blocks}}{[}{j}{]}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{then}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{blocks}}{[}{j}{]}{≔}{\mathrm{blocks}}{[}{N}{]}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{N}{≔}{N}{-}{1}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{found}}{≔}{\mathrm{true}}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{break}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end if}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end do}}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{if}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{not}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{found}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{then}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{return}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{false}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end if}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end do}}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{return}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{true}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (3)



Let's restart and then reference the procedure from the "abc.mla" repository that we saved it in:

$\mathrm{restart};$

We can use the procedure:

$\mathrm{canSpell}\left("good"\right);$

 ${\mathrm{true}}$ (4)

But we can no longer see the implementation:

$\mathrm{eval}\left(\mathrm{canSpell}\right);$

 ${\mathbf{proc}}\left({w}\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}}{\mathbf{local}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{blocks}}{,}{i}{,}{j}{,}{\mathrm{word}}{,}{\mathrm{found}}{,}{N}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{"2f0b0404264baa44a4bc758aa04e5b18e763f64743733b1443d884fbae3db43aa9f7602fc86ade456f648e4965c66765bc9ae483a741f33e7906cb36c2c9f8d8571c607892e334a524080dc68f96c7ee03127724368a0b44518f210cc61a58ef47668d7415828c6e4de386370634e04754d32a723d154802511873d5b144d08ba5c8d544356a5126d8d39e047de4fb7251107155148450fca5c8d5443d6a51265be4a391eb29d40e51197165d872d08ba5c8d5443a6a512690f1bf332a8a69ef511a71556c8450fc402c48ce1744215c81a7ede7e8baefb3a5c8d544396a5126208cee0573051de2ff10f544e08e25c34119983289241252bdbc456f5124c54684d0a607a99430dae81d6220cc795ad05e54c1fe2ab47fa3d4b4515eb853703920a8ac666e690a744934462441290b6e62016dc6f0f1d3dc45b49f2d356d666ebcf3c846116cc4ef57d407aeef5ccc29c3c4a776c0780b78a86eabbfffc16dc83ceb6e4776963171fe468b8fde1fcfbbe01d9f706c057c45b2803d6931787b36c93468625240bced45e82c676e653427f554f621d038706303149886f5921caac96f01288b3e65433f340647989334611766b05d3938b5f3e7454c42c6377bade609147920fb7524357aa946133c235b6c5f0da1705c06234890d7203931aee0dcbdb9463b07c955262c3767463e376773c1580fd747af44f886db6e4e5d4e213c1858365a9155f3464d8865464f286496b060ab4849d13be286ee895dccbb34b5702271feedf925a0f3ae271bde5e8fb3a23115a91b68450ee0363559c35c9c2fb90e0dd5e19e0855ee6f1ee160d3cf42214a72f881889b6a12a672e9a4ac901c586a522fc4ada9b3a23115a91b6845501e43e0ce2a70a605f8e546c8e73d0c77b6167d1e940cf63b204a72fd818c2b6a12a672e9a4ac90eb8a55f4090fbbbdf5c67915591b68475fca58199eeb812588b80bba9b3f503cefcfecb90abb19ad3fa65273f881bc1342d8283a711dac4975a663a6467186466c4669989d283f7116f3b81d3d4e4faf"}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (5)