I am trying to create a proprietary function as discussed in this link:
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
Encodeuse 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:38DumpSave..." I took "encryption" to refer toEncode– IntroductionToProbability May 01 '23 at 16:54