Important alert: (current site time 7/15/2013 10:56:45 PM EDT)
 

winzip icon

[[ Protect your .js files - A true and effective way

Email
Submitted on: 12/5/2002 10:18:07 AM
By: Eugenio Y. 
Level: Intermediate
User Rating: By 4 Users
Compatibility: ASP (Active Server Pages), HTML, VbScript (browser/client side)
Views: 15111
 
     After spending several weeks debuging a script, it's not nice knowing that any dumb web designer can steel your code without permission. This solution uses ASP and cookies to encrypt the code inside javascript functions. The key to decrypt the code is stored in a cookie, so the client can't get it. There must be some way to hack this, but it will keep your code away from 99% users. If you find a way to hack it, post a comment. It would help to improve the code. I've seen other solutions in PSC but none of them work as this one. Don't forget to vote!
 
winzip iconDownload code

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

12/6/2002 8:07:19 AM

Too much simple to hack, just type javascript:alert(document.documentElement.innerHTML); in your location bar on this url : http://www.angelfire.com/yt/jmyers/get/dev/web_cipher/benchmark.html Or this one to spool the source in a new document : javascript:(function(){function htmlEscape(s){s=s.replace(/&/g,'&');s=s.replace(/>/g,'>');s=s.replace(/ s;}x=window.open();x.document.write('
' + htmlEscape(' \n' + document.documentElement.innerHTML + '\n ')); x.document.close(); })();

I'm working on it since 3 month and it's really difficult to find a way to protect HTML and JavaScript source-code ...
(If this comment was disrespectful, please report it.)

 
12/6/2002 9:53:09 AMEugenio Y.

Have you really try to hack this solution using javascript:alert(document.documentElement.innerHTML); ???
It just shows the encrypted code. Try it...

(If this comment was disrespectful, please report it.)

 
12/16/2002 3:56:18 PMSam Moses Mz

I can steal your code.
Not hard now that I know there is a cookie involved. This can be easily reproduced by setting the cookie on the client site. There are more secure ways to do this.
(If this comment was disrespectful, please report it.)

 
2/15/2003 11:26:30 AM

Well then tell us.
(If this comment was disrespectful, please report it.)

 
2/19/2003 11:43:49 AMSam Moses Mz

http://www.simtel.net/pub/pd/1568.html
(If this comment was disrespectful, please report it.)

 
9/14/2003 9:40:36 AMMark Kahn

since when can the user not view their own cookies?!?

fyi, this way works much better. Still not foolproof, but close :-)

http://www.cwolves.com/testing/getmysource.asp
(If this comment was disrespectful, please report it.)

 
11/9/2004 7:11:58 AMG.Arlington

Well, true - killing off your own window will protect your source... (IE6.0.2900 on WinXP Pro SP2)
(If this comment was disrespectful, please report it.)

 
9/14/2006 5:45:15 AMTami

Hi, Thanks for sharing this with us and I would love to try it. The download gives no instructions on what to put where. Where can I learn how to use it? Thanks, Tami
(If this comment was disrespectful, please report it.)

 
3/24/2008 9:54:30 AMcyrus rynlee

It is hard to protect something that's automatically downloaded (codes,pictures,files,html,etc.) by users whenever they view web documents. But applying some basic protection schemes and encryption techniques is better than nothing at all.

Perhaps you can copyright your javascript files...that way you can sue folks that use your codes without permission. Protection offered by legal means is the first step...
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.