An earlier question of mine, Prevent package from being opened in a notebook interface, never received an answer, but Albert Retey's comments did lead me to an entirely different solution.
To secure my Mathematica code for distribution to a client I now plan to wrap encoded Mathematica code in C# code and compile it to a DLL. The client will then call the DLL from their .NET application with specific methods that will call my proprietary Mathematica functions. My compiled code will handle all .NET/Link operations.
Wrapping encoded code in a DLL may seem like overkill (well I still tie double knots in my shoelaces). I just want to make the code as secure as possible and as I have to do the compiling on my client's Window's machine (I use Mac) I want to do everything to keep it from curious eyes.
I've written a package and encoded it. I've tested the package in the client environment by loading the encoded package file from a notebook interface. This works fine.
I've done a second test. In a notebook, I copied the encoded text and pasted it into a cell and assigned it to a variable, something like:
myEncodedString = "(*!1N!*)mcm j<hTJue'P+lKh]7t>X#r/N5>m^c0Q j,fdE~0y@X>TkncC'AMluD1_R3,0?vQR0(n|p08B D\O%!1o3t~`#0VL...a bunch more encoded text..."
Following this I tried:
This didn't work. I revisited what I needed to do and realized I could make it work by using the form
Get[stream] and tried the following:
This gave me the following dialogue box:
Selecting "Yes" ran the code and made all of its function definitions available.
Now I tried to do the same thing from C# via .NET/Link, which did not work. I think it didn't work because I need some way to insert escapes in the encoded text.
Does anyone have an idea of how to do this or more generally how to get this to work?