0

I am trying to create a proprietary function as discussed in this link:

How to distribute proprietary Mathematica code

So I create a function and dump it into a file

f[x_Real] := x^2 + 1;
SetAttributes[f, {ReadProtected, Locked}]

SetDirectory[$TemporaryDirectory]; DumpSave["notEncodedFunction.mx", f]

After I quit and load the file it works

Quit[]

SetDirectory[$TemporaryDirectory]; Get["notEncodedFunction.mx"] f[5.1]

27.01

I now try to repeat the above but with an encoded version and it fails

Quit[]

SetDirectory[$TemporaryDirectory]; Encode["notEncodedFunction.mx", "encodedFunction.mx"];

Get["encodedFunction.mx"]; f[5.1]

f[5.1]

I feel I am overlooking something obvious here but what?

PS: If copying the code to the notebook please split put the Quit[] line in its own cell

  • 2
    The only examples I see for Encode use plain text files, not binary formats like MX. I can't say whether what you are seeing is a bug or not. But I am curious what the intent is for encoding an MX file - the file format is not readable except by the kernel. – Jason B. May 01 '23 at 16:38
  • Following the answer in the link: "...to use a combination of encryption, DumpSave..." I took "encryption" to refer to Encode – IntroductionToProbability May 01 '23 at 16:54

0 Answers0