Solved

Javascript Encription - is it possible ??

Posted on 2004-03-23
7
734 Views
Last Modified: 2009-12-16
Hi All,

Is it possible to encript javascript but still it works in Internet Explorer and Netscape?
0
Comment
Question by:meet_zorrer
7 Comments
 
LVL 25

Expert Comment

by:devic
ID: 10656973
no,
if you find something, do not forget to test it ;)
look in my profile a tester :)
0
 
LVL 4

Author Comment

by:meet_zorrer
ID: 10656992
if you are tester then you should test your mind first :D
0
 
LVL 63

Accepted Solution

by:
Zvonko earned 168 total points
ID: 10657133
Hello meet_zorrer,

the initial question is: why do you want to encrypt your JavaScript?
If you want to prevent modification or prevent removing of some license enforcement, then it can not be absolutely done, but to some degree you can encode your script by algorithm which are difficult to follow and backtrack.
If you want only to make it difficult to be read by humans, then a regular scrambler and space remover will do it too.

But at the end I can prove you that any encoded script can be decoded, when the effort is worth of doing it.
Also for the Microsoft IE script compiler are decompiler out there (for demo purposes :)

0
 
LVL 10

Assisted Solution

by:Nushi
Nushi earned 166 total points
ID: 10657343
hi there.

you can only encrypt the js from IE.
you can find a small took called srcenc which will encode the script and you will not be able to see it.

BUT you can use the same tool for decone and encode so someone whi knows what to do will be able to "see" the code.
under NS you will not be able to run it.
0
 
LVL 16

Assisted Solution

by:jaysolomon
jaysolomon earned 166 total points
ID: 10657760
Here are a number of very effective methods of keeping unscrupulous surfers from stealing your HTML source:

Use the <INVISIBLE> </INVISIBLE> tags around the entire document.
Use the DONTSTEAL attribute in the <BODY> tag.
Ftp to your server, select all files and directories, hit "Delete".
Put every existing copy of every file on floppies, place them in a shoebox and bury them in the backyard. There is another version of this method which involves placing the floppies in a plastic bag and hiding them in a different sort of hole. Both are equally effective.
Password protect your entire site and make sure no one has the password, not even you.
Employ a small but fanatically loyal and well-armed band of mercenaries to guard your site.
Start>Run>format C:\
Attack dogs, preferably rabid.
Use any version of Microsoft Frontpage to create your site. (This won't prevent people from viewing your source, but no one will want to steal it.)
Don't put your pages on the web.
See also the alt.html micro-faq: http://hyweljenkins.com/support/mfaq.htm #1, #2, #6, #19, #20, #22 & #36.

Ok, that was a bit of fun. Here's the real lowdown on hiding your source code:

It can't be done.
The only truly effective method in the list above is #10.

While it is possible to make it difficult for people to view your source code, you cannot stop someone who really wants it. It has been suggested that using javascript to disable right-click or encrypting the HTML may be effective. It is far more likely that employing these easily circumvented techniques will only encourage people to "steal" your code. In all probability, they don't want it until you tell them they can't have it.

For example: Here is page- http://prestigiousdames.com/char/57_chevy -where the author is laboring under the misapprehension that employing all manner of legitimate-user-infuriating scripting tricks will prevent their page from being copied/edited/distributed. They have attempted to encrypt the source, intercept right-clicks, left-clicks and various keyboard commands and have, of course, most conspicuously failed. The only thing this author has succeeded in doing is to create a page that presents serious obstacles to legitimate users and one that will crash many commonly used browsers. A simple snippet of javascript defeats all of this foolishness in under two seconds:

javascript:(function(){ function htmlEscape(s){s=s.replace(/&/g,'&');s=s.replace(/>/g,'></g,'<');return s;} x=window.open(); x.document.write('>');s=s.replace(/pre>' + htmlEscape('\n' + document.documentElement.innerHTML + '\n')); x.document.close(); })();

To use this javascript simply right-click the following link and select "add to favorites": Reveal Generated Source (Use IE5.0 or greater)

Now point your browser at http://prestigiousdames.com/char/57_chevy and once the page is displayed, go to the bookmark you just made. All of the encryption is stripped out leaving a clean copy of the HTML source to do with as you see fit. Images from the page may be saved by dragging them from the page into a local folder, or by going directly to their individual URLs.

The point of this little demonstration is that there are a number of ways to protect your works from unauthorized distribution. Creating crippled pages with easily defeated script-kiddie hacks is not one of them.

Beware, there are individuals and companies that sell HTML "protection" to the naive. These are nothing more than scams; don't get taken for a ride.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now