?
Solved

how to hide code in java scripts

Posted on 2003-03-19
5
Medium Priority
?
259 Views
Last Modified: 2006-11-17
hi there
Well i have to hide the java script code on the server. that is the code written in .js file extention and called in asp page. but in this case one can edit the code on server side. So is there any code hidden / encryption techniques available?. So that no one can easily temper the code in js file.
regards
usman
0
Comment
Question by:usmanshahid
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 11

Expert Comment

by:fargo
ID: 8172654
Hii,

Well what do u mean by someone can edit the code on the server side?? To hide the javascript code u can make use of external js files.

for ex:
<SCRIPT LANGUAGE="JavaScript" SRC="urfilepath.js"></SCRIPT>

revert back if u have any problems.

hope this helps.
thanks and regards
0
 
LVL 3

Expert Comment

by:vosk
ID: 8173639
I don't think that externals scripts can hide the javScript code because you can open the direction (url pagefolfolder + *.js filename) and download as all formats. Maybe the most secure way is using some security code, something like cgi to read from a server file, so you cannot have acces. But that is too many writing for something like that.
Surely that there's a lot of pages with encrypt techniques, but I only know www.astalavista.com
That page is updated every day (or every month), and sometimes I have seen some encryption articles. Maybe you can find something useful.
jbosch(vosk)
0
 
LVL 1

Expert Comment

by:Antithesis
ID: 8173790
Maybe you could use a server side language to verify that the request is coming from one of the pages.  I've never really wanted to hide javascript this badly, so I've never looked into it.
0
 

Author Comment

by:usmanshahid
ID: 8175645
hi all
Well i was talking about that when a client requests for a page then the java scripts code also comes to him even u place java scripts code in seperate .js extention file. and also one who has access the webserver can also temper the java scripts.SO is there any method how u hide/ encrypted code from both..i.e client one and from server one.
regards
usman
0
 
LVL 3

Accepted Solution

by:
vosk earned 60 total points
ID: 8179729
Take a look to the script that calls your *.js file:
<script src="file.js"></script>
Is necessary to carge both files (html + js) because the html needs the surce from where read the javascript codes and execute them as faster as the pc lets.
The other solution about read from the server with some security scripting will convert your page into a "please wait while first function is loading..." "please wait while second function is loading..." "please wait while third function is loading..." and I really wouldn't like to wait and wait in front of my pc while a simple javascript code is loading separately depending of what function is needed (and I'm not the only user that thinks that). Also I'm not sure that a simple interval can run dynamically with in this way.

Another thing is that you don't want to leave the used files on the user's temporary folder. Then is there a way to do that: a meta tag that tells to the browser that on exit from the page remove all the files that the page have had to charge on the temp folder. But I didn't used never and I don't know if that is the tag that I mean:
<META HTTP-EQUIV="Expires" CONTENT="0">
That tag prevents the page to being cached, but I don't know if that means that won't leave temp files or that always is readed from the server (even during the same session), or both things... But also you won't hide the js file, always will be accessible do download it.
If you are thinking about make a password with javascript an hide the code, the better way is to forget that idea and learn to use php, cgi, asp or other security code. Do not encrypt because then you'll need to decrypt all the code, and that means a lot of time and a lot of script (surely complicated script).
Hope that now you have a clearer idea about what do you want: speed or slowness with a lot of scripting.
Also hope that will help you.
jbosch(vosk)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question