473,387 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

The best way to protect javascript code?

if speed, size is not a matter, i just want to protect the code as much
as possible, any library or tools do you think is the best solution
right now?

i know there is not a perfect solution, but as good as it can be is
okay...

p.s. need to be cross brower

thanks.

Dec 9 '06 #1
7 16792
howa wrote:
if speed, size is not a matter, i just want to protect the code as much
as possible, any library or tools do you think is the best solution
right now?

i know there is not a perfect solution, but as good as it can be is
okay...

p.s. need to be cross brower

There are zillions of obfusicators

google javascript obfuscation

Here is one but I don't know if it works well.
http://dean.edwards.name/packer/

There is always a risk of introducing bugs when obfusicating code and
the code won't be uncrackable.

http://yuiblog.com/blog/2006/03/06/m...v-obfuscation/

Peter

Dec 9 '06 #2
howa wrote on 09 dec 2006 in comp.lang.javascript:
if speed, size is not a matter, i just want to protect the code as much
as possible, any library or tools do you think is the best solution
right now?

i know there is not a perfect solution, but as good as it can be is
okay...

p.s. need to be cross brower
If your code is worth protecting, you will know alreadiy,
that protected JS can only be serverside JS.

If your clientside JS is worth being stolen,
no scheme will help you.

If your clientside JS is not worth being stolen,
why bother?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Dec 9 '06 #3
You can make it a lot harder by using PHP or some sort of server side
language (PHP just happens to be my language of choice), and then
including the javascript and linking to it externally. In the PHP make
sure that the refferer is your site and if it isn't, dont print out the
page.

Dec 9 '06 #4
mo********@gmail.com wrote:
You can make it a lot harder by using PHP or some sort of server side
language (PHP just happens to be my language of choice), and then
including the javascript and linking to it externally. In the PHP make
sure that the refferer is your site and if it isn't, dont print out the
page.
The source has to be sent to the client. This technique does not make
it a lot harder to see the source. I am pretty darn sure it is still
visible with something like http://getfirebug.com

Peter

Dec 9 '06 #5
mo********@gmail.com wrote on 09 dec 2006 in comp.lang.javascript:
>
You can make it a lot harder by
Are you replying one something?

[please always quote on usenet]

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Dec 9 '06 #6
Peter Michaux wrote:
mo********@gmail.com wrote:
>You can make it a lot harder by using PHP or some sort of
server side language (PHP just happens to be my language of
choice), and then including the javascript and linking to it
externally. In the PHP make sure that the refferer is your
site and if it isn't, dont print out the page.

The source has to be sent to the client. This technique does
not make it a lot harder to see the source. I am pretty darn
sure it is still visible with something like
http://getfirebug.com
There is no need get that complicated; view the files in the browser's
cache while the site is loaded and the external javascript files will be
there, regardless of whether they were dynamically greeted with
PHP/ASP/JSP or whatever, or just text files of JS source code.

The catch is always that the client-side code has to be sent the client,
and in a form that can be understood as javascript source code. As a
result the client will always have, at some point, the client-side code,
and in a form that can be understood.

For every code minimiser there is a code re-formatter or pretty printer
to turn the compacted code back into recognisably formatted/indented
code (with some of the browsers themselves being entirely adequate tools
for that job through the use of a little (publicly available and well
known) scripting). Then there is syntax highlighting to bring out the
distinctions between, for example, operators, keywords and Identifiers.

Which leaves the only potentially practical/productive aspect of
obfuscation the transformation of property names and Identifiers into
meaningless sequences of characters, which is not really a barrier to
understanding computer code. It may be true that meaningful
Identifiers/property names are an aid to (more quickly) understanding
source code but if their absence represented any real barrier the fact
that the vast bulk of example code (and all of the browser DOM property
names and language keywords) are in English must then make it near
impossible for non-English speakers to understand those examples (or the
DOM). This clearly is not the case. Obfuscation by Identifier scrambling
is of limited benefit because a word that is meaningful in a language
that the reader does not understand is no more or less meaningful to
them than any arbitrary sequence of characters that it may be replaced
with.

The pro-obfuscation position (and particularly those retailing
obfuscation software) will argue that obfuscation must make code harder
to understand. That is true, but the degree to which it is harder to
understand is so small (and so much not a real issue to the people who
could have understood the code directly if it were never obfuscated)
that the effort outweighs the benefits.

Plus, once obfuscated what are you going to do when a browser reports:-

Error: Line 1, character 5734, "I0O1I is null or not an object"

-?

Richard.
Dec 10 '06 #7
In comp.lang.javascript message
<el*******************@news.demon.co.uk>, Sun, 10 Dec 2006 03:41:20,
Richard Cornford <Ri*****@litotes.demon.co.ukwrote:
... ...
>Plus, once obfuscated what are you going to do when a browser reports:-

Error: Line 1, character 5734, "I0O1I is null or not an object"
A sane author will retain the unobfuscated code and can run that in the
same browser, expecting a corresponding result; then fixing the master
and publishing a re-obfuscated version.

You're rather naive in the interpretation of your knowledge.

There is perceived future benefit in being able to prevent others from
seeing or from understanding one's code. Generally, those others will
be, at least predominantly, those unable to code (in the perceiver's
opinion) as well as the perceiver - persons with less knowledge or
ability than those who want to hide their code.

Those who expect to be able to hide their code must believe it to be
probably possible to do so; so a substantial proportion of the less able
will believe it too, and so will not in fact read the code in question.

In other words, code hiding / obfuscation is partially effective. It
cannot hide code from, say, Jim Ley; but it can hide it from such as
Ja********@freemail.com. Also, if an expert believes that, because code
cannot be properly hidden, hidden code must be by an incompetent author,
he might well not bother to look - and the hider's aim is achieved.

Remember "The Purloined Letter"?

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/- FAQqish topics, acronyms & links;
Astro stuff via astron-1.htm, gravity0.htm ; quotings.htm, pascal.htm, etc.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
Dec 10 '06 #8

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

Similar topics

11
by: Amilcar | last post by:
Hi: I have a problem: I've a page that sends an encrypted password, using MD5, to a PHP file, which is able to compare such MD5 encrypted password with an encryption stored on a data base. But...
131
by: Peter Foti | last post by:
Simple question... which is better to use for defining font sizes and why? px and em seem to be the leading candidates. I know what the general answer is going to be, but I'm hoping to ultimately...
3
by: philsmithy | last post by:
first downlaod this plugin for the script to work, then upload it t your server if you wish http://www.htmlblock.co.uk/plugin.zip Once you have install that plugin visit ...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
4
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I protect my javascript code? ----------------------------------------------------------------------- ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
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...
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.