Enzo wrote:
[color=blue]
> It's possible to protect the source code of
> a js file? With PHP?
>[/color]
No, there is nothing which you can do to stop even moderately intelligent
users from seeing your js source code. Microsoft have an option to
'encrypt' js files but (a) this means your js will only ever run on IE, and
(b) 2 minutes with Google will find you a utility to unencrypt the js.
You can try using a javascript obfuscator to remove comments and whitespace
and replace meaningful variable names with shorter meaningless ones, but
the main benefit of this is that it reduces download times, and it does
make it more painful if you ever have to debug anything.
Enzo wrote:[color=blue]
> Hi Ng,
>
> It's possible to protect the source code of
> a js file? With PHP?
>
> Thanks in advance!
>
> Enzo[/color]
not really.
the js file needs to be executed on the users computer, so the code has
to get there somehow. the browser must be able to read the code, and if
the browser can, so can the user.
php has got nothing to do with that at all, cause it runs on the
server, which is somewhere else at all.
In article <nl2be.136205$I 96.145937@telen ews.teleline.es >, vaya@mierda.pai s says...[color=blue]
> Hi Ng,
>
> It's possible to protect the source code of
> a js file? With PHP?[/color]
"Duncan Booth" <duncan.booth@i nvalid.invalid> wrote in message
news:Xns96436BD 60BFA7duncanrcp couk@127.0.0.1. ..[color=blue]
> Enzo wrote:
>[color=green]
> > It's possible to protect the source code of a js file?[/color][/color]
[color=blue]
> No, there is nothing which you can do to stop even moderately intelligent
> users from seeing your js source code. Microsoft have an option to
> 'encrypt' js files but (a) this means your js will only ever run on IE,[/color]
and[color=blue]
> (b) 2 minutes with Google will find you a utility to unencrypt the js.
>
> You can try using a javascript obfuscator to remove comments and[/color]
whitespace[color=blue]
> and replace meaningful variable names with shorter meaningless ones, but
> the main benefit of this is that it reduces download times, and it does
> make it more painful if you ever have to debug anything.[/color]
We make such obfuscators. Yes, they remove comments/whitespace,
and make the names meaningless. Yes, this does benefit
download time, but it really does, in our opinion, make code
of any serious size very difficult to understand, which is where
you get your protection.
They have NO impact on development debugging.
You keep your source in cleartext, so you code and
debug it exactly as you have. You obfuscate the code
just before you go live with it in production, keeping
your cleartext for further development.
If you get an error report from the field, generated obfuscation maps
let you easily convert scrambled names back to the real ones.
(You customers of course don't get these generated maps,
only you do).
--
Ira D. Baxter, CTO 512-250-1018
Semantic Designs, Inc.
Ira Baxter wrote:[color=blue]
> Duncan Booth wrote:[color=green]
>> Enzo wrote:[color=darkred]
>> > It's possible to protect the source code of a js file?[/color][/color]
>[color=green]
>> No, there is nothing which you can do to stop even
>> moderately intelligent users from seeing your js source
>> code. Microsoft have an option to 'encrypt' js files but
>> (a) this means your js will only ever run on IE, and (b)
>> 2 minutes with Google will find you a utility to unencrypt
>> the js.
>>
>> You can try using a javascript obfuscator to remove
>> comments and whitespace and replace meaningful variable
>> names with shorter meaningless ones, but the main benefit
>> of this is that it reduces download times, and it does
>> make it more painful if you ever have to debug anything.[/color]
>
> We make such obfuscators.[/color]
So your keep saying.
[color=blue]
> Yes, they remove comments/whitespace,
> and make the names meaningless.[/color]
But the removal of white space is not a contribution to obfuscation
because it is always possible to get a code formatter to put it back.
[color=blue]
> Yes, this does benefit download time,[/color]
It has been demonstrated many times that the compression facilities of
HTTP 1.1 will have an approximately equivalent effect in reducing
download time, and carry that effect on to HTML source.
But if the point of processing source code in a way that modified
identifier names is going to be to reduce the size of the resulting code
it would be better to use an obfuscator that transformed the names to
the shortest valid identifiers available in the pertinent scope.
[color=blue]
> but it really does, in our opinion, make code
> of any serious size very difficult to understand,
> which is where you get your protection.[/color]
Your opinion seems to be colored by a vested interest. You are yet to
get a single regular contributor to this group to agree with it.
[color=blue]
> They have NO impact on development debugging.
> You keep your source in cleartext, so you code and
> debug it exactly as you have. You obfuscate the code
> just before you go live with it in production,[/color]
You absolutely do not obfuscate code just before you go live with it. If
you are going to obfuscate code you need to do so _before_ QA, and then
QA again each time your re-obfuscate the original source.
Of course it is possible that semdesigns.com don't do QA so you don't
realise the need for this.
[color=blue]
> keeping your cleartext for further development.
>
> If you get an error report from the field, generated
> obfuscation maps let you easily convert scrambled names
> back to the real ones. (You customers of course don't get
> these generated maps, only you do).[/color]
The premise that identifier names need to be meaningful for code to be
understood is utterly wrong.
> We make such obfuscators. Yes, they remove comments/whitespace,[color=blue]
> and make the names meaningless. Yes, this does benefit
> download time, but it really does, in our opinion, make code
> of any serious size very difficult to understand, which is where
> you get your protection.
>
> They have NO impact on development debugging.
> You keep your source in cleartext, so you code and
> debug it exactly as you have. You obfuscate the code
> just before you go live with it in production, keeping
> your cleartext for further development.
>
> If you get an error report from the field, generated obfuscation maps
> let you easily convert scrambled names back to the real ones.
> (You customers of course don't get these generated maps,
> only you do).[/color]
There is a standing challenge in this group to people making claims
about obfuscation and code hiding to prove their claims by giving us a
test case.
In previous trials, code was recovered and posted in the clear within
minutes.
Obfuscation is a waste of time. It does not work. It will not protect
secrets. It will increase development costs.
JSMin, which is free and open, can remove comments and whitespace. That,
followed by compression, can significantly reduce download times. It is
also as effective as obfuscation in keeping competent programmers from
seeing the source. That is why JSMin makes no such claims.
Douglas Crockford wrote:[color=blue]
> There is a standing challenge in this group to people making claims
> about obfuscation and code hiding to prove their claims by giving us a
> test case.
> In previous trials, code was recovered and posted in the clear within
> minutes.
> Obfuscation is a waste of time. It does not work. It will not protect
> secrets. It will increase development costs.[/color]
The goals of the obfuscation need to be made clear.
No amount of obfuscation will stop knowledgeable javascript coders from
gaining full readable access to your code. But, I don't think that's the
goal in most cases.
If the goal is to stop most web users - and probably most average javascript
coders - from duplicating your code and/or methods, then obfuscation
probably works just fine. Most people probably lack the knowledge or skill
to get anything useful from the obfuscated code. It should be made clear
that you will never protect your code from 100% of users. But if protecting
it from 80% (or whatever percent, I know you'll complain about random stats,
Richard) is acceptable and you think it is beneficial, then obfuscation
might achieve your goal.
Now, whether it's worth anyone's time to protected against a subset of all
internet users - that depends on the situation.
>>There is a standing challenge in this group to people making claims[color=blue][color=green]
>>about obfuscation and code hiding to prove their claims by giving us
>>a test case. In previous trials, code was recovered and posted in the
>>clear within minutes.[/color][/color]
[color=blue][color=green]
>>Obfuscation is a waste of time. It does not work. It will not protect
>>secrets. It will increase development costs.[/color][/color]
[color=blue]
> The goals of the obfuscation need to be made clear.
>
> No amount of obfuscation will stop knowledgeable javascript coders from
> gaining full readable access to your code. But, I don't think that's the
> goal in most cases.
>
> If the goal is to stop most web users - and probably most average javascript
> coders - from duplicating your code and/or methods, then obfuscation
> probably works just fine. Most people probably lack the knowledge or skill
> to get anything useful from the obfuscated code. It should be made clear
> that you will never protect your code from 100% of users. But if protecting
> it from 80% (or whatever percent, I know you'll complain about random stats,
> Richard) is acceptable and you think it is beneficial, then obfuscation
> might achieve your goal.
>
> Now, whether it's worth anyone's time to protected against a subset of all
> internet users - that depends on the situation.[/color]
What commercial benefit is obtained from preventing unknowledgeable
coders from seeing your code? Accepting for a moment your statistic
that 80% of web developers are incompetent, it is the remaining 20%
that represent a competitive threat.
Matt Kruse wrote:
<snip>[color=blue]
> No amount of obfuscation will stop knowledgeable javascript
> coders from gaining full readable access to your code. But,
> I don't think that's the goal in most cases.
>
> If the goal is to stop most web users - and probably most
> average javascript coders - from duplicating your code and/or
> methods, then obfuscation probably works just fine.[/color]
Any action to protect code form 'most web users' is a total waste of
time and effort (and money if you pay for software to do it), they don't
understand computer code anyway.
It is not until people start to learn javascript that there is any point
in trying to conceal code from them. And for any individual script a
reader's ability to comprehend it will depend on the extent to which
their skills match those required to employ the techniques used in the
script. A newbee will be utterly baffled by an OO javascript, and
intermediate authors are often incapable of comprehending closure-based
code.
Ultimately the problem of obfuscation is that any script that is worth
protection only really needs protection from the one group against whom
there is no protection; the people who would actually understand the
source code in its plain form.
[color=blue]
> Most people probably lack the knowledge or skill
> to get anything useful from the obfuscated code.[/color]
Precisely. The vast majority of people don't understand any computer
code, obfuscated or not.
[color=blue]
> It should be made clear that you will never protect
> your code from 100% of users. But if protecting it from
> 80% (or whatever percent, I know you'll complain about
> random stats, Richard)[/color]
Most don't need reminding that if its random it is not a statistic, just
a number.
You could try stating that these numbers you post are just your personal
baseless guesses, and everyone could assign then the weight they deserve
without the need for additional comment.
[color=blue]
> is acceptable and you think it is beneficial,
> then obfuscation might achieve your goal.[/color]
For the vast majority obfuscation is an unnecessary step. They will not
understand the code anyway.
[color=blue]
> Now, whether it's worth anyone's time to protected against
> a subset of all internet users - that depends on the situation.[/color]
For any given script there is a majority who wouldn't understand any of
it (in any form), a group that will understand some of it, but not
comprehend the totality, and a group that would fully comprehend the
script. No effort is needed to 'protect' a script against the first two
groups, and nobody is realistically claiming that obfuscation will be
effective against the third.
In short; obfuscation with the intention of providing 'protection' is
wasted effort.
"Richard Cornford" <Richard@litote s.demon.co.uk> wrote in message
news:d50h1a$o0m $1$8302bc10@new s.demon.co.uk.. .[color=blue]
> Ira Baxter wrote:[color=green]
> > Duncan Booth wrote:[color=darkred]
> >> Enzo wrote:
> >> > It's possible to protect the source code of a js file?[/color]
> >[color=darkred]
> >> You can try using a javascript obfuscator to remove
> >> comments and whitespace and replace meaningful variable
> >> names with shorter meaningless ones, but the main benefit
> >> of this is that it reduces download times, and it does
> >> make it more painful if you ever have to debug anything.[/color]
> >
> > We make such obfuscators.[/color]
>
> So you keep saying.[/color]
So we do.
[color=blue][color=green]
> > Yes, they remove comments/whitespace,
> > and make the names meaningless.[/color]
>
> But the removal of white space is not a contribution to obfuscation
> because it is always possible to get a code formatter to put it back.[/color]
Sure. I repeat, once again that obfuscation (and any kind of
"protection ") offers NO GUARANTEES. Obfuscation simply
provides a level of defense that requires effort on the part of
a thief. Once the economics from the theif's point of view
are poor, you've won.
Reformatting isn't particularly hard, granted.
Nontheless, the results still look scary (even if they aren't
in a technical sense), and that chases off some of the potential
thieves. No, don't repeat your argument about chasing off only
dumb theives, we've all heard it. Chasing off dumb theives is
still valuable, and this isn't the only defense.
[color=blue][color=green]
> > Yes, this does benefit download time,[/color][/color]
[color=blue]
> It has been demonstrated many times that the compression facilities of
> HTTP 1.1 will have an approximately equivalent effect in reducing
> download time, and carry that effect on to HTML source.[/color]
Agreed. This isn't the point of obfuscation, merely an extra benefit.
Neither end has to actually set up the compression capabilities to get it
when you use obfuscation.
[color=blue]
> But if the point of processing source code in a way that modified
> identifier names is going to be to reduce the size of the resulting code
> it would be better to use an obfuscator that transformed the names to
> the shortest valid identifiers available in the pertinent scope.[/color]
Sure. We could squeeze out an extra few percent if we went this
far, but nobody has told us that it matters. (I responded to a previous
post of yours that said we didn't produce the shortest possible
identifiers; true, but in practice we come pretty close).
Building products is about economics, too, and what
the obfuscator does seems to be reasonable without going
this far.
[color=blue][color=green]
> > but it really does, in our opinion, make code
> > of any serious size very difficult to understand,
> > which is where you get your protection.[/color]
>
> Your opinion seems to be colored by a vested interest.[/color]
I'll cheerfully agree SD has a vested interest. It got that way
because people asked us to build such obfuscators.
You are welcome to vote by not buying one.
[color=blue]
> You are yet to
> get a single regular contributor to this group to agree with it.[/color]
I doubt if my customers want to spend a lot of time in
this kind of discussion. There have been several other
defenders of the utility of obfuscation involved in these
threads (Matt Kruse in this one). I don't know if
he is a "regular contributor", and I don't see why
"regular contributor" should carry specific weight.
We all have our opinions. Reasoned dicussions
seem fine.
[color=blue][color=green]
> > They have NO impact on development debugging.
> > You keep your source in cleartext, so you code and
> > debug it exactly as you have. You obfuscate the code
> > just before you go live with it in production,[/color][/color]
[color=blue]
> You absolutely do not obfuscate code just before you go live with it. If
> you are going to obfuscate code you need to do so _before_ QA, and then
> QA again each time your re-obfuscate the original source.[/color]
Yes, the way I stated could be interpreted as
"obuscate-then-ship-in-2-nanoseconds".
I meant it in "do your development, then finish up your usual way
(including test if you have any sense), and then ship."
If you didn't have your own point of view to push, I think
you reasonably might have interpreted this a bit more
loosely. We're not trying to prove theorems here.
[color=blue]
> Of course it is possible that semdesigns.com don't do QA so you don't
> realise the need for this.[/color]
Yes, it is *possible*. It is *possible* you are an axe murderer.
Then again, perhaps we actually do QA, and you are not.
Ad hominem attacks don't contribute to this discussion.
[color=blue]
> The premise that identifier names need to be meaningful for code to be
> understood is utterly wrong.[/color]
For small codes, sure. For larger codes... almost everybody on the planet
agrees that maintaining somebody else's code is difficult; see any software
engineering textbook. The usual recommendation is that an engineer(!)
design carefully, code carefully, choose meaningful names, and document
it all. The usual practice seems much worse, and almost all maintenance
is based on reading the existing code and praying the last guy at least
used sensible names. If he hasn't done that, then working out what the
code
does tends to be much harder.
"Douglas Crockford" <nospam@covad.n et> wrote in message
news:c6552$4273 d623$436562f7$2 1482@msgid.mega newsservers.com ...[color=blue][color=green]
> > [Baxter wrote]
> > We make such obfuscators. Yes, they remove comments/whitespace,
> > and make the names meaningless. Yes, this does benefit
> > download time, but it really does, in our opinion, make code
> > of any serious size very difficult to understand, which is where
> > you get your protection.
> >
> > They have NO impact on development debugging.
> > You keep your source in cleartext, so you code and
> > debug it exactly as you have. You obfuscate the code
> > just before you go live with it in production, keeping
> > your cleartext for further development.
> >
> > If you get an error report from the field, generated obfuscation maps
> > let you easily convert scrambled names back to the real ones.
> > (You customers of course don't get these generated maps,
> > only you do).[/color]
>
> There is a standing challenge in this group to people making claims
> about obfuscation and code hiding to prove their claims by giving us a
> test case.
>
> In previous trials, code was recovered and posted in the clear within
> minutes.[/color]
I don't recall seeing such trials. You may have had them.
We haven't participated in such.
[color=blue]
> Obfuscation is a waste of time. It does not work. It will not protect
> secrets.[/color]
In an absolute sense, sure. In an absolute sense, nothing works
perfectly. Practical solutions have their limits, and are usable
within those limits. Whether you think the limits are reasonable
is a matter of judgement. Some others judge differently than you.
[color=blue]
> It will increase development costs.[/color]
Yes, yes, its true! One can actually spend *an entire afternoon*
setting up obfuscation for typical JavaScript stuff.
(Many cases related to obfuscating JS for IE take only a few
minutes). But the increment is miniscule.
[color=blue]
> JSMin, which is free and open, can remove comments and whitespace. That,
> followed by compression, can significantly reduce download times.[/color]
A previous post said this was wasted effort, since HTTP 1.1 handles it
better;
I assume you leave *all* the identifiers in place, intact..
However, I agree with you that doing this has some value since you can't
always know that both parties support HTTP 1.1. compression.
(Hard to believe how old some browser out there running are...)
[color=blue]
> It is also as effective as obfuscation in keeping competent programmers[/color]
from[color=blue]
> seeing the source. That is why JSMin makes no such claims.[/color]
I disagree about its ability to make the source difficult to decode.
Garbled identifiers in larger codes make them harder to figure out.
However, you are welcome to not use any obfuscation tools.
>>There is a standing challenge in this group to people making claims[color=blue][color=green]
>>about obfuscation and code hiding to prove their claims by giving us a
>>test case.
>>
>>In previous trials, code was recovered and posted in the clear within
>>minutes.[/color][/color]
[color=blue]
> I don't recall seeing such trials. You may have had them.
>
> We haven't participated in such.[/color]
You are not the only person to have made bogus claims about the value
of obfuscation. If you are unwilling to put your claims to a public
test, that is, as they say, your business.
Hywel Jenkins wrote:
[color=blue]
> vaya@mierda.pai s says...[color=green]
>> It's possible to protect the source code of
>> a js file? With PHP?[/color]
>
> In PHP:
> unlink("filenam e.js");[/color]
Comment