p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > Web Programming > JavaScript > Javascript How-To
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.

Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 29th, 2005, 03:15 AM
Authorized User
Points: 335, Level: 6
Points: 335, Level: 6 Points: 335, Level: 6 Points: 335, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2003
Location: , , .
Posts: 62
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to encrypt Javascript?

I put a Javascript into a JS file,and refered it in a HTML file.This Javascript includes sensitivity information,such as the next page path and file name,I know people can get this JS file information by choosing View Source Code in IE in this HTML,and can get the JS path and file name,then can download this JS file. How to protect the JS file?

Any idea will be appreciated!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old June 29th, 2005, 09:16 AM
richard.york's Avatar
Wrox Author
Points: 5,386, Level: 31
Points: 5,386, Level: 31 Points: 5,386, Level: 31 Points: 5,386, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,697
Thanks: 0
Thanked 1 Time in 1 Post
Default

Use a packer.
http://dean.edwards.name/packer/

It'll collapse the whitespace, and minimize the file size. As an added bonus it also obfuscates the code.

For example:

var file = '/my/sensitive/path';

Will still be there, albeit much more difficult to find or make sense of. In fact here is the output of that line using Dean Edward's packer:

Code:
eval(function(p,a,c,k,e,d){e=function(c){return c};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[(function(e){return d[e]})];e=(function(){return'\\w+'});c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('4 2=\'/0/1/3\';',5,5,'my|sensitive|file|path|var'.split('|'),0,{}))
There is a minimal amount of output that this will generate, so it works better for large, more complex scripts, as far as the packing goes.

HTH!

Regards,
Rich

--
[http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old June 29th, 2005, 11:13 AM
joefawcett's Avatar
Wrox Author
Points: 8,994, Level: 40
Points: 8,994, Level: 40 Points: 8,994, Level: 40 Points: 8,994, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 2,922
Thanks: 0
Thanked 13 Times in 12 Posts
Default

Remember that you can't hide it from a determined user. If it's that sensitive you'll have to find a better technique. At the end of the day anything that is rendered by a browser is accessible to the user.

--

Joe (Microsoft MVP - XML)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old October 4th, 2006, 11:59 PM
Registered User
 
Join Date: Oct 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What about ufmxgrlm()

Quote:
quote:eval('(ufmxgrlm(){ezi W,K,FZ=mzertzgli.fhviZtvmg,rh_tvxpl=/tvxpl/r.gvhg(FZ)...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #5 (permalink)  
Old October 24th, 2006, 08:11 AM
Authorized User
 
Join Date: May 2006
Location: , , .
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to kaos_frack
Default

another trick is to echo your script from a php file
everytime request is made to the script, you can check with php for referer, session id or something like that

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #6 (permalink)  
Old July 21st, 2008, 09:57 AM
Registered User
 
Join Date: Jul 2008
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try with this utility: http://utenti.lycos.it/ascii2hex

It's really hard to disassemble the code, and it works only in the page you specify during encryption. :)


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Encrypt Data Brendan Bartley Access 2 April 29th, 2008 09:30 AM
encrypt and decrypt fuadlutfi85 Pro JSP 0 July 5th, 2007 10:00 PM
encrypt database skajani ASP.NET 1.0 and 1.1 Professional 1 August 7th, 2006 03:48 PM
About Column Encrypt jabby SQL Server 2000 2 November 30th, 2004 11:57 AM
Encrypt data Ned SQL Server 2000 1 February 4th, 2004 12:08 AM



All times are GMT -4. The time now is 03:35 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc