INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Hiding source code

How to hide your source code by Supra
Posted: 30 Apr 04

This is the oldest question there ever was.  The simple answer is: "You CAN'T hide your source code, period."  However, I realize there are some people who would like to try.  This FAQ will not criticize those users, it will provide information on how they can make it a little harder for users to look at their code.  Elders - do not flame this FAQ.  It is a very heavily requested topic whether it is right or not to hide your source code.

The first step is to remove the context menu from your webpage.  The following code will stop the context menu from popping up when a user right-clicks the page.  Insert this code after your <head> tag.


<script>
<!--
document.oncontextmenu = new Function("return false");
//-->
</script>


Another method is to load a Macromedia Flash file in a hidden frame.  This doesn't mean to put an object tag in a hidden frame and load the Flash file that way, this means to load the actual SWF in the hidden frame.  This has been known to disable the View->Source option in Internet Explorer's menu bar.  I have not tested this with IE6 however.

To further protect your code, you may want to "encrypt" it using a JavaScript powered binary ecrypter by Matthew Tong.  It's very nicely done and very hard to decipher (assuming the user doesn't know where to find the decrypting code), but it's also pretty slow when it decrypts.

The link is: http://javascript.internet.com/miscellaneous/matts-encrypter.html

As previously stated, hiding your source code will probably never be 100% possible, and the internet is (for the most part) designed to be open source.  Please use the information in this FAQ only as a reference, not a tutorial.

Back to Javascript FAQ Index
Back to Javascript Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close