Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Apr 2007
    Thanked 0 Times in 0 Posts

    encrypt the js file

    Hi guys,

    Im long back to this forum. Im having a query with the js file encryption. Im having a js file and i had included that .js file in php. I like to know whether there is any option to encrypt the js file so that the file will be protected.

    Pls let me know asap.


    Be friend of me
    Hey what a fun

  2. #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    London, England
    Thanked 2,715 Times in 2,689 Posts
    Use a packer.

    It'll collapse the whitespace, and minimize the file size. As an added bonus it also obfuscates the code. But remember that you cannot hide your code from a determined user. Why do you want your .js "protecting"? What is so confidential about it?

    Also have a look at:-


    But you will find that this may slow the web page quite a lot.
    Last edited by Philip M; Oct 11th, 2007 at 07:31 AM.

  3. #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Sydney, Australia
    Thanked 932 Times in 919 Posts
    You can encrypt your page content using JavaScript so that the page can only be viewed by someone who knows the password. Anyone with the password will be able to view the decrypted page source.

    If you don't use a password then anyone can view a readable copy of the page source. The browser has to undo any obfuscations of the code in order to be able to display the page and anyone who knows how can view that version. Unpacking JavaScript back into a more readable format is just a matter of feeding the code into a formatter script.

    The only real protection for any obfuscated or packed JavaScript is basically that anyone who knows how to convert it back into something readable also knows enough JavaScript to write their own version and so has no reason to want to take yours.
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts