Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
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 Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old June 29th, 2005, 03:15 AM
Authorized User
 
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!

Reply With Quote
  #2 (permalink)  
Old June 29th, 2005, 09:16 AM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 5 Times in 5 Posts
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
Reply With Quote
  #3 (permalink)  
Old June 29th, 2005, 11:13 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 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)
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)...
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

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. :)


Reply With Quote
  #7 (permalink)  
Old August 11th, 2011, 06:40 AM
Registered User
 
Join Date: Aug 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is an old thread but I hope I can still get answer from you.

I am also a fan of this script but the problem is (as what you have said) it will work only on the page you specify. Is it possible for the script to work in all pages? If the URL is used as the key to encrypt the javascript, can it be change to something else instead of the URL?

Quote:
Originally Posted by billgates View Post
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. :)
Reply With Quote
Reply


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 08:45 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.