Recommend a way to encrypt Javascript code

vulcanman

Senior member
Apr 11, 2001
614
0
0
What the best way to encrypt some javascript code I want to put on my web site ?

If javascript is not secure ... whats another way to accomplish the task.

Basically, I have a custom calculator that I want to make available but don't want anyone to see the formula I use. Thanks in advance.

My website is hosted on a linux server.
 

Drakkon

Diamond Member
Aug 14, 2001
8,401
1
0
http://www.javascript-source.com/ - here is a obfuscator that kinda works but people could still figure out your code if they looked hard enough. Search for other obfuscators and they might give you better ways - its not exactly encrypted just makes it more difficult to figure out.

javascript is really close to actionscript - maybe convert the calculator to flash?
Flash is encryptable - use a tool called Amayeta SWFEncrypt
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
You can't really secure anything that the client has to download and use locally like HTML and Javascript. Either do it server-side or give in to the fact that anyone who really wants to know will figure it out.
 

vulcanman

Senior member
Apr 11, 2001
614
0
0
Can someone point me to an example to show how server side PHP works. Could someone potentially be able to access that php server-sde file that has the code ?
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
Could someone potentially be able to access that php server-sde file that has the code ?

If the server isn't properly secured and they break in, sure.
 

Atheus

Diamond Member
Jun 7, 2005
7,313
2
0
Originally posted by: Nothinman
Could someone potentially be able to access that php server-sde file that has the code ?

If the server isn't properly secured and they break in, sure.

But otherwise no....

It is much more secure than client side code.

If I were you I might do an AJAX request to the server and avoid reloading the page, but even then you have to consider the load on your machine vs theirs, and the fact that they still have to wait a few hundred ms or more for the answer.

Is the secrecy of your algorithm really that important to you? There are plenty of free Javascript libraries which will do math functions for you...
 

vulcanman

Senior member
Apr 11, 2001
614
0
0
I will be generating revenue from the ads on the web page. Its emperative that people visit the site to use my utilities. Thats the only reason.

Thanks all !
 

statik213

Golden Member
Oct 31, 2004
1,654
0
0
Originally posted by: vulcanman
I will be generating revenue from the ads on the web page. Its emperative that people visit the site to use my utilities. Thats the only reason.

Thanks all !

If this is being hosted on your site then start learning PHP...
You can safely run your calculator on your web server and not have anyone see your source code; they would only see your results.

btw I'm saying learn PHP 'cos it's the easiest stuff to host. Ruby, Python etc are much better languages than PHP but aren't as freely host-able.
 

aceO07

Diamond Member
Nov 6, 2000
4,491
0
76
Learn server side coding, essentially what most people have said. This will leave all the logic on the server.

Just out of curiosity, what kind of calculations are you performing in javascript?
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,838
4,817
75
If you're going for obfuscation, e.g. to fool ad-blocking programs, here's a weird one.

Edit: To be clear, I believe you can put any HTML or Javascript in there, and when the page loads, it will run the Javascript, write out the contained Javascript, and then run it, too. But I haven't tested that.
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Originally posted by: Ken_g6
If you're going for obfuscation, e.g. to fool ad-blocking programs, here's a weird one.

Edit: To be clear, I believe you can put any HTML or Javascript in there, and when the page loads, it will run the Javascript, write out the contained Javascript, and then run it, too. But I haven't tested that.
Well, that's probably more useful for saving bandwidth sending large scripts (although gzip compression handled by the browser would be much better). It would obfuscate the code somewhat but it would be trivial to find out the real code that's running with a little effort.