Is there any free Javascript Obsfucator available?
Actually I just want the obsfucator to do two things...
1. Remove Comments
2. Rename Functions and Variables
15 4196
You may find JSMin useful (at least for the first objective).
You may find JSMin useful (at least for the first objective).
I downloaded the PHP code and made a php file to upload the required js file.
Like this:
[PHP]<?php
//file name: minify.php
if (!isset($_POST['Submit']))
{
?>
<html>
<form action=minify.php method=post enctype="multipart/form-data">
<input type=file name=js></input>
<input type=submit name=Submit value=Minify>
</form>
</html>
<?php
}
else
{
include('jsmin-1.1.0.php');
if ($_FILES['js']['error']>0)
die ('Error Uploading File');
$file_js = fopen($_FILES['js']['tmp_name'],"r");
$js = fread($file_js,$_FILES['js']['size']);
//echo $js;
$min = new JSMin;
$minified = $min->minify($js);
//echo $minified;
}
?>[/PHP]
But it gives this warning... Missing argument 1 for JSMin::__construct()
What to do...
PS: I don't understand OOP Concepts :(
I suggest you ask in the PHP forum.
I suggest you ask in the PHP forum.
Yeah, you are right!!
My fault!!
I use firefox to compress it.
wrap your code in a function, then compress by using the .toSource() method on the function.
Example: -
function BS(){
-
-
-
function el2(tid) {
-
return document.getElementById(tid);
-
}
-
-
function tags(elm, tid) {
-
if (tid) {
-
if (elm.isString) {
-
elm = el(elm);
-
}
-
return obValsl(elm.getElementsByTagName(tid));
-
}
-
return obValsl(document.getElementsByTagName(elm));
-
}
-
-
}
-
-
-
alert(BS.toSource())
-
/* returns:
-
function BS() {
-
function el2(tid) {return document.getElementById(tid);}
-
-
function tags(elm, tid) {if (tid) {if (elm.isString) {elm = el(elm);}return obValsl(elm.getElementsByTagName(tid));}return obValsl(document.getElementsByTagName(elm));}
-
} */
-
remember to remove the first and last line of the resulting text, the function wrapper.
I use firefox to compress it.
wrap your code in a function, then compress by using the .toSource() method on the function.
Nice tip (for compression, at least)!
Is there any free Javascript Obsfucator available?
Actually I just want the obsfucator to do two things...
1. Remove Comments
2. Rename Functions and Variables
By the way, is this just to cut down on the size of the script? This is what minification is for.
@acoder
Yeah, coz I ended up making at least 10 js files of all approx 25 kb. So I wanted to cut down the size. And I know the actual code size (w/o comments and spaces) is approx 15 kb, may be less than that. @rnd me
Cool!! Thanks... :)
@acoder
Yeah, coz I ended up making at least 10 js files of all approx 25 kb. So I wanted to cut down the size. And I know the actual code size (w/o comments and spaces) is approx 15 kb, may be less than that.
So, did you manage to cut it down in size?
So, did you manage to cut it down in size?
I didn't do it yet...
Will do after testing.
Will tell you how much file size reduces...
remember that in javascript, variable names are case-sensitive, so performing global replaces on compressed code could be an easy way to obfuscate names.
if you have a funciton or prototype for doing mulitple replaces, you could feed it a an array of function names, and have it substitute a serial number for each.
continuing above, -
-
String.prototype.substitute = function (r) {
-
O = this;
-
for (z = 0; z < r.length; z++) {
-
tre = new RegExp(r[z][0], "gm");
-
O = O.replace(tre, r[z][1]);
-
}
-
return O;
-
}
-
-
-
function serial(dig) {
-
var bb = "";
-
if(!dig){ dig=5; }
-
for (var q = 0; q < dig; q = q + 1) {
-
bb = bb + String.fromCharCode(Math.round(Math.random() * 25 + 65));
-
}
-
return bb;
-
}
-
-
var subs=[
-
["el2",serial()],
-
[ "tags", serial()]
-
] //end sub array
-
alert(BS.toSource().substitute(subs) )
-
-
So, did you manage to cut it down in size?
Yeah, quite a lot.
A 32kb well commented JS was reduced to 19 kb.
And a 15 kb, non-commented JS reduced to 14 kb (not too much tho :p)
Yeah, quite a lot.
A 32kb well commented JS was reduced to 19 kb.
And a 15 kb, non-commented JS reduced to 14 kb (not too much tho :p)
Every little helps, eh?
If you're using long names for variables, functions, etc. you may want to replace those too.
Every little helps, eh?
If you're using long names for variables, functions, etc. you may want to replace those too.
Yeah, I wanted to, but the thing you referred to didn't do that :p
And I don't want to do the find replace thing. B'coz with that, when I would do any change, after doing that with the original (commented) file, I would need to do the whole find-replace thing again.
So I wanted a one-click-solution, so that after making any change, I can get the minified* version quickly and upload it to server again. * term used by that guy who made that program.
Yeah, I wanted to, but the thing you referred to didn't do that :p
And I don't want to do the find replace thing. B'coz with that, when I would do any change, after doing that with the original (commented) file, I would need to do the whole find-replace thing again.
So I wanted a one-click-solution, so that after making any change, I can get the minified* version quickly and upload it to server again. * term used by that guy who made that program.
Try YUI Compressor, Packer or ShrinkSafe (Dojo).
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Smugsboy |
last post by:
Anyone.
Where can I find a free javascript scrambler/obfuscator, that can be
ran from command-line.
Is there one that can be used as a frontpage plugin ?
Thanks,
|
by: Luke Matuszewski |
last post by:
Hi,
Can anyone point me for some JavaScript Obfuscators ? I know one
written by Dean Edwards (but it do not substitute variable names, which
a would like to do).
B.R.
Luke Matuszewski
|
by: korund |
last post by:
I want encrypt javascript code in web page, however, browser need fully
recognize it.. There any many Javascript Obfuscators in the Net. Is
there some good and handy utility(or script) among them...
|
by: mistral |
last post by:
Neeed good javascript unescape encoder, to protect javascript code.
Some advices? Online tool, or ready javascript only.
Any opinions about the Javascript Obfuscator:...
|
by: twigster |
last post by:
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
|
by: FAQ server |
last post by:
-----------------------------------------------------------------------
FAQ Topic - How do I protect my javascript code?
-----------------------------------------------------------------------
...
|
by: Laurent Bugnion [MVP] |
last post by:
Hi group,
A few years ago, I translated Douglas Crockford's JsMin from C to C#,
because we wanted to use this functionality in our build process. JsMin
is a code minimizer for JavaScript. It...
|
by: Peter Michaux |
last post by:
Hi,
I've uploaded a new version of the JavaScript::Minifier module that
was on CPAN. It was a translation of JSMin but I rewrote it so it now
handles missing semicolons, + ++ code, and leaves...
|
by: =?iso-8859-1?q?Martin_M=FCcke?= |
last post by:
Hi,
I am looking for a good javascript obfuscator - I found several on the
web, but I am looking for one that can also handle javascript in jsp,
html and java files - so I need a javascript...
|
by: crymari2 |
last post by:
Hello,
I have a need to make my javascript really difficult to study.
A lot of people think that this is useless waste of resources, but they are wrong IMHO.
I need your recommendation of...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |