# Is it possible to prevent users from seeing the package codes while they still can make use of its publicly exposed macros?

Assume that I have a confidential package that nobody is allowed to see the source code. The users are only allowed to use the public macros. This question is closely related to my other question.

\documentclass{article}
\usepackage{mypackage}% it is allowed.
\usepackage{listings}

\begin{document}
\publicmacro% it is allowed.
\lstinputlisting{mypackage.sty}% it is not allowed.
\end{document}


Is it possible to prevent users from seeing the package codes while they still can make use of its publicly exposed macros?

-
I assume that the code has to be loadable at point-of-use, not for example 'pre-built' into a custom format file? –  Joseph Wright Aug 31 '12 at 8:35
The real question is: why do you need it? –  tohecz Aug 31 '12 at 8:57
@tohecz: I want to rent some computers in my internet cafe for other to write homeworks, thesis, etc but I don't want to let them know my settings. If they know my setting then I have no income. :-) –  Please don't touch Aug 31 '12 at 9:05
Then you want to have the LaTeX on a server and the people using it from there. In that case they cannot see your texmf tree at all, and after some tweaking of \show and \tracing... you should be able to hide the code completely. –  tohecz Aug 31 '12 at 9:10
@tohecz: But it will make my server more vulnerable because smart TeX users can exploit my server, right? –  Please don't touch Aug 31 '12 at 9:12
show 2 more comments

The short answer is 'no'. TeX is a macro expansion language, which means that there is no 'compiled code' you can use: the closest you can get is to make a custom format (a format file pre-builds the code into an internal binary format). You could also make the code tricky to read using techniques such as those in xii.tex. Even if you did that, your users can \show your macros, or use \tracingall to see what is happening. Your therefore more likely to make your own life harder in maintaining your code by doing such tricks than you are to prevent the curious from seeing what is happening.
+1 for xii :) I was just about to add: you can always name your macros a crazy way with no real sense. –  tohecz Aug 31 '12 at 8:57
I recently wrote some code to take a TeX source, find repeated patterns, and replace them by macros. This could be used as a step to make the source code less readable. It could also be modified to turn macro names into an unreadable mess, so that \show and \tracingall cannnot give insight into what is happening. Unfortunately, if you use packages, you would have to copy them as a new file (otherwise your users would see which packages you load), and also obfuscate those (otherwise your users would be able to search for which package have those internal macros).