Probably Encode and tricks as David outlined are enough for the normal client.
However, the more fundamental problem is that Encode
does not encrypt. So by definition it is not safe (see e.g. : here).
The only really safe way (if you protect your webserver from behing hacked into),
is to use good old webMathematica, since the Wolfram Language source code only resides on the server,
just the input and output is transferred from and to the user.
If you do not mind that your code is in the cloud (i.e., always readable by some
system administrator at Amazon or Wolfram at least), the Wolfram Programming Cloud might also be a possibility,
once it is out of Beta, of course.