This thread covers some of the thoughts/options regarding code encryption:
I believe the new GHPython compile options implement the same .NET functionality that I linked to back then. So that might be a place to start.
Edit: And in turn, this thread: