473,554 Members | 2,834 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Obfuscate Javascript

Hey everyone,

I'm looking for a good way to obfuscate some Javascript code. Does
anyone have a good experience or bad experience with a particular software?

thanks
Aug 17 '06 #1
20 3257
twigster wrote on 17 aug 2006 in comp.lang.javas cript:
I'm looking for a good way to obfuscate some Javascript code. Does
anyone have a good experience or bad experience with a particular
software?
Read the NG'a archive. This Q is asked every week or so.

.... and you will come to the inevitable conclusion
that the need for clientside obfuscation is nonsense.

[... and that that for serverside obfuscation is too.]

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Aug 17 '06 #2
MB
I'm looking for a good way to obfuscate some Javascript code. Does anyone
have a good experience or bad experience with a particular software?
Not really a obfuscator, but you could try a beta version of my Javascript
Cruncher which offers REAL compression of javascript files. Obfuscation
comes as a "side effect" of this compression.

http://www.fanskap.se/crunch

Aug 17 '06 #3
twigster wrote :
Hey everyone,

I'm looking for a good way to obfuscate some Javascript code. Does
anyone have a good experience or bad experience with a particular software?

thanks
Follow this link :

http://dean.edwards.name/weblog/2005/02/packer2-beta/

Note : ALL your commands/blocks should be ended with a ';' , or it
might result in syntax errors. For example :

var foo = function(e) {
var i = 0;
switch (e) {
case 0:
if ( e == i ) {
sayHello();
};
break;
};
};

function sayHello() {
alert( "hello" );
};

Aug 17 '06 #4
};
(forgot the last ending brace... :) but you get the idea !)

Aug 17 '06 #5
MB wrote:
>I'm looking for a good way to obfuscate some Javascript code.
Does anyone have a good experience or bad experience with
a particular software?

Not really a obfuscator, but you could try a beta version of my
Javascript Cruncher which offers REAL compression of javascript
files. Obfuscation comes as a "side effect" of this compression.

http://www.fanskap.se/crunch
Wouldn't it have been a good idea to test that a little before
proposing that anyone use it? As it stands the use of - eval - to
generate the actual 'executable' javascript inside an anonymous
function called as a constructor leaves any global function
declarations and global variable declarations in the original code
defining inner functions and f unction local variables. As a result
they are all inaccessible from the global scope, and will be invisible
to, for example, intrinsic event handlers defined in the HTML, or code
in other script files, or code in separate SCRIPT elements.

However, as an obfuscator it suffers from the usual problem that the
code that expands the data into javascript source code is provided in
the resulting file, and can then easily be used to recover the original
code (with the usual re-formatting courtesy of Mozilla/Gecko browsers).

Richard.

Aug 17 '06 #6
MB
Wouldn't it have been a good idea to test that a little before
proposing that anyone use it? As it stands the use of - eval - to
generate the actual 'executable' javascript inside an anonymous
function called as a constructor leaves any global function
declarations and global variable declarations in the original code
defining inner functions and f unction local variables. As a result
they are all inaccessible from the global scope, and will be invisible
to, for example, intrinsic event handlers defined in the HTML, or code
in other script files, or code in separate SCRIPT elements.

However, as an obfuscator it suffers from the usual problem that the
code that expands the data into javascript source code is provided in
the resulting file, and can then easily be used to recover the original
code (with the usual re-formatting courtesy of Mozilla/Gecko browsers).
As I said, it's a beta version and by that I mean "not finished". It will
have various options for how the decrunched data is made available to the
browser, etc.

Second, it is not intended to "protect" the javascript code in any way. It's
intended to make it smaller. The "obfuscatio n" is, as I said in the first
post, a "side effect". It is not the intent with the cruncher.

Everybody should know that protecting javascript is not possible. Take
programs like HTML guardian for example. You pay money for a false sense of
security. No matter how much you obfuscate or encrypt your javascript, if
the browser can run the code, you can also view it. The bottom line is, the
browser runs the decryption code, then has the decrypted code in a variable,
then makes it available to the document by using document.write( ) or eval().
Try this (tested in IE): Make a bookmark in your browser. As a URL, paste in
this:
javascript:void (document.body. innerText=docum ent.documentEle ment.innerHTML)
Now go to http://www.protware.com and then their demonstration page. Now
click that bookmark and you'll see the document body replaced by the
encrypted source and further down the decrypted source in plain view. So
much for protection.

You can never be safe, but you can at least save some bandwith by crunching.
Aug 17 '06 #7

twigster wrote:
Hey everyone,

I'm looking for a good way to obfuscate some Javascript code. Does
anyone have a good experience or bad experience with a particular software?

thanks
Interesting question since in my experience most js programmers start
off with obfuscated code. ;-)
though not js specific, this makes a good read
http://mindprod.com/jgloss/unmain.html

Aug 17 '06 #8
MB said the following on 8/17/2006 10:01 AM:
Try this (tested in IE): Make a bookmark in your browser. As a URL, paste in
this:
javascript:void (document.body. innerText=docum ent.documentEle ment.innerHTML)
I prefer this one better:

javascript:'<co de><ol><li>'+(d ocument.documen tElement||docum ent.body).outer HTML.replace(/&/g,"&amp;").repl ace(/</g,"&lt;").repla ce(/%20%20/g,"&nbsp;%20"). replace(/(\n\r?|\r)/g,"<li>")+'<\/ol><\/code>';
Now go to http://www.protware.com and then their demonstration page. Now
click that bookmark and you'll see the document body replaced by the
encrypted source and further down the decrypted source in plain view. So
much for protection.

You can never be safe, but you can at least save some bandwith by crunching.
There are better ways than "crunching" .

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Aug 17 '06 #9
twigster wrote:
Hey everyone,

I'm looking for a good way to obfuscate some Javascript code. Does
anyone have a good experience or bad experience with a particular software?

thanks
See the one at

http://www.jasob.com/

which is a commerical product and will cost money after the evaluation
runs out. I am not affiliated with this company, but I do believe the
product is worth the money.

I use it routinely to compress big JS files into relatively small ones.
(I am more interested in the "compressio n" than "obfuscatio n", but the
two are closely related.)

Blue Apricot

Aug 17 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
4245
by: mthlv12 | last post by:
I am using the latest version of eclipse to develop a java application. Is there an obfuscate button in eclipse ?
2
3753
by: mthlv12 | last post by:
Does the eclipse ide have an obfuscate button ?
3
2071
by: Aaron | last post by:
How would code obfuscation affect performance? in .net C#
11
3550
by: J.L.Cooper | last post by:
I have been looking at the winning entries for the International Obfuscated C Contest (Shame I missed it till it had closed, well next time I will get an entry in) and I was wondering if anyone has any good suggestions for tricks that can be used to Obfuscate C code. * Some trick that I like to use include the following. a^=a; instead...
11
3010
by: RF | last post by:
Hi All, I need some help from experts of preparing an application for obfuscation and installation. A solution with two projects: 1. I have a standard windows form app with an implemented custom installer class. 2. I have a standard setup referencing the "output" of the above app and implementing the custom actions from the custom...
20
4141
by: Drebin | last post by:
It's a long story really, but the bottom line is we need to encrypt or obfuscate a clear-text 9-digit SSN/taxpayer ID into something less than 21 characters. It doesn't need to be super-secure, just something that isn't plain-text and it HAS to be as unique as the original number. It also does not need to be a symmetric algorithm - we are...
0
1748
by: nelmr | last post by:
Hey guys, I've tried and tried to find a walk thru that works. Since I am using VS C# 2008 express, i am using clickonce deployment. I am targeting the 2.0 framework as I am not using any 3.5 features. Here is my issue and questions: 1) I have a c# program that I would like to publish to my website (it does NOT have front page extensions,...
2
11610
hsriat
by: hsriat | last post by:
For a good programmer, providing good comments in the code is a must. In PHP, giving comments has no demerits. But what about JavaScript? Do you really want those comments to stay in the code and make it double in size, and of course disclose what you have done when the code reaches the client (browser)? I am not sure how many of you would have...
0
7578
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7497
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7862
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6119
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5414
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5136
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3530
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1994
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
812
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.