PDA

View Full Version : How do I hide my Javascript code?


susandel
01-23-2003, 04:59 AM
What's the best method of making Javascript code hard to steal?

Obviously as a browser-dependent scripting language, it's impossible to hide it. But is there some way of scrambling it.... making it "more trouble than it's worth" for only the most dedicated code thief?

Thanks!

joh6nn
01-23-2003, 05:14 AM
well, we have a big long thread about this: http://www.codingforums.com/showthread.php?s=&threadid=4437

there are ways to scramble it, make it more difficult, but mostly, anyone who is at all interested in stealing it, is gonna know enough to get around most of the ways of scrambling it.

so, it's not worth it.

Borgtex
01-23-2003, 10:37 AM
I'm not afraid of the man who wants to see scripts' code. I'm terrified of the man who wants to hide them
:D

joeframbach
01-23-2003, 01:33 PM
there was a good movie on tv the other day. it's called antitrust. good movie, go watch it!

knowledge is for the world!

Vladdy
01-23-2003, 05:37 PM
Originally posted by susandel
What's the best method of making Javascript code hard to steal?
My favourite is: putting the *.js file on the floppy and doing "format a:\"

Seriously, no encription or anything else of that nature will stop someone who knows what they are doing. However making your code easily accessible and planting a "bug" in it, may fool even some seasoned veterans (ask beetle, he knows :D :D :D)...

Danne
01-23-2003, 05:47 PM
Originally posted by Vladdy
However making your code easily accessible and planting a "bug" in it, may fool even some seasoned veterans


How evil... :p

Vladdy
01-23-2003, 05:58 PM
Originally posted by Danne
How evil... :p
By copying my scripts one forfeits his right to fair game ;)

matthewb
01-23-2003, 06:09 PM
Hello,

Since you actually asked how to make it *hard* to steal your code rather than *impossible*, I'll give you an easy answer.

I was recently in the same situation where I thought a client might try to 'steal' the code for their website without paying for it.

I used a piece of shareware called Web Protector. It scrambles the page using JavaScript to a chosen degree of security. It does make a *real* mess of it - and you have to keep a copy of your original files because it doesn't do the same thing backwards.

http://www.protecthtml.com/

It's got pretty high ratings on most of the shareware sites, and I think it's pretty good; though I *would* advise not to use the highest security on a *huge* page because it can make the page a bit slow.

Best of luck with whatever-it-is-you're-up-to.

Matthew

PS: Yeah, it's costs some money; but not much really.

Vladdy
01-23-2003, 06:43 PM
Don't even waste your money on the webprotector and such products. They are just half step above a plain scam.
Here is the source to http://www.protecthtml.com/product/wp/sample31.htm
plain and simple...

<HTML>
<HEAD>
<META http-equiv="Expires" content="-1"/>
<TITLE>Sample</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<META name="keywords" content="html encryption, encrypt html, html encrypt, protect html, web site protection, web protection, web page encryption, web page protection, protect image, java script encrypt, protect web page, protect web site, protect html code, html protect, encrypt java script, encrypt image, protect web page source code, web site security, net security"/>
<META name="description" content="Protect your Web Page, including HTML code, JavaScript, VBscript, text, links, graphics from unwanted copying."/>
<META name="copyright" content="GoldStone Software, Inc."/>
<LINK rel="stylesheet" href="../../gsstyle.css"/>
</HEAD>
<BODY bgcolor="#ffffff">
<CENTER>
<TABLE width="607" border="0" cellspacing="0" cellpadding="0" height="276">
<TBODY>
<TR>
<TD colspan="2" height="51">
<CENTER>
<B>Sample</B>
</CENTER>
</TD>
</TR>
<TR>
<TD height="214" width="156">
<IMG src="../../images/wplogo.gif" width="130" height="149" alt="Web Protector - Protect your Web Page!"/>
</TD>
<TD height="214" width="451">
<P>
<B>
Web Protector 2.0 </B>
<FONT color="#ff0000">
<B>
*NEW* </B>
</FONT>
</P>
<P>
Web Protector helps you protect your Web Page, including HTML code, JavaScript, VBscript, text, links, graphics from unwanted copying. It encrypts your Web Page by as much as six encryption schemes and make the source code impossible for people to read and steal, however, the look of your Web Page will not be anged in any common JavaScript compatible browser. Many additional features are available in order to further protect your Web Page, for example, Full disable right click, Disable text selection, page printing, offline use, and so on. </P>
</TD>
</TR>
<TR>
<TD colspan="2" height="40">
<DIV align="right">
<IMG src="../../images/dl.gif" width="18" height="18" align="middle"/>
<A href="../../download/index.htm#wp">
<B>
FREE Download! </B>
</A>
</DIV>
</TD>
</TR>
<TR>
<TD colspan="2" height="103">
<CENTER>
<TABLE width="566" border="0" cellspacing="0" cellpadding="0">
<TBODY>
<TR>
<TD height="34" width="97">
<A href="../../reg/index.htm#wp">
<IMG src="../../images/buy1.gif" width="80"
height="50" align="middle" alt="Buy Web Protector" border="0"/>
</A>
</TD>
<TD height="34" width="464">
Click this button to order online. It's
fast and secure! You will receive your registration information
immediately after payment. </TD>
</TR>
</TBODY>
</TABLE>
</CENTER>
</TD>
</TR>
<TR>
<TD colspan="2" height="293">
<P>
This page is protected by these option combinations: </P>
<CENTER>
<TABLE width="364" border="0" cellspacing="0" cellpadding="0">

<TBODY>
<TR>

<TD height="25">
<IMG src="../../images/opt.gif" width="11" height="11"/>

Encryption Scheme V </TD>

</TR>

<TR>

<TD height="25">
<IMG src="../../images/opt.gif" width="11" height="11"/>

Full disable right click </TD>

</TR>

<TR>

<TD height="25">
<IMG src="../../images/opt.gif" width="11" height="11"/>

Disable text selection </TD>

</TR>

<TR>

<TD height="25">
<IMG src="../../images/opt.gif" width="11" height="11"/>

Disable offline use </TD>

</TR>

<TR>

<TD height="25">
<IMG src="../../images/opt.gif" width="11" height="11"/>

Do not display links in status bar </TD>

</TR>

<TR>

<TD height="25">
<IMG src="../../images/opt.gif" width="11" height="11"/>

Disable page printing </TD>

</TR>

<TR>

<TD height="25">
&nbsp; </TD>

</TR>

<TR>

<TD height="25">
&nbsp; </TD>

</TR>

</TBODY>
</TABLE>

</CENTER>

<P align="center">
&nbsp; </P>

</TD>

</TR>

</TBODY>
</TABLE>

</CENTER>

</BODY>
</HTML>

matthewb
01-23-2003, 06:57 PM
Yeah, but Vladdy, as it says, you're a CF addict.

That puts you above the ordinary mortal :p Innit.

Matthew

Vladdy
01-23-2003, 07:13 PM
Viewing page in mozilla (with DOM inspector installed) and hitting Ctrl-Shift-I does not take much brain power....

beetle
01-23-2003, 07:18 PM
Hey Vladdy, at first when you mentioned my name, I didn't know what you were talking about, but I remember now :D

In case you people listening in don't know what we're talking about, I was using a script Vladdy wrote (his DOM viewer, VERY cool tool) to help me with a page I was working on. Nowhere on his site does it say not to use the script w/o permission or anything like that, so I promptly copied the JS file from his server and stuck it on mine. The easy availability of the script was it's strength in letting Vladdy know what was going on. I never inspected the code, it just worked and that's all I needed. But, hidden inside was a 'bug' that reported back (http://www.codingforums.com/showthread.php?s=&threadid=10134) to Vladdy's domain.

Pretty neat, and VERY sneaky :D

whammy
01-23-2003, 11:30 PM
Generally, only people new to web design and programming tend to worry about "code theft". I'm not being derogatory by stating that, as my very own first script was a "password script", like many new developers - and I too asked the famous "source code" question at one time, as probably most of us here have. :D

Believe me, give yourself a while and you'll see what I mean.

Now that we've covered all of that again, you can do a few things to make it harder for a "non-programmer" simply trying to pilfer your scripts, i.e. a javascript "cut and paster"...

• If you have several interdependent functions, store them as separate external javascript libraries, and include them on the page where they will be used.

• Use some of the more advanced techniques, i.e. objects, functions which use parameters, regular expressions, booleans, ternary operators, etc. - basically things that a javascript "cut and paster" wouldn't know how to modify, although a seasoned programmer wouldn't have a problem with it...

• "Crunch" your code... (i.e. take out extra white space, making it hard to read). You'll find some javascript "crunchers" with a search of the forum or a google search.

Now, after you've done all of that, and you've misplaced your original easy-to-read script sometime next year, have fun putting all of the pieces back together if you find a need to use it on another site. It's definitely not worth it.

:)

CGameProgrammer
01-24-2003, 01:56 AM
Personally I find most webscripts too simple to be worth worrying over. Nearly all of them merely affect the display or interface of a webpage; it's not like program source code.

The only copy-paster protection I would bother with is putting your name in comments in a few places around the script (if it's a large script).