Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable or encrypt "View Source" for my site

Tags:

javascript

php

Is there any way to disable or encrypt "View Source" for my site so that I can secure my code?

like image 332
Fero Avatar asked Nov 27 '22 20:11

Fero


2 Answers

Fero,

Your question doesn't make much sense. The "View Source" is showing the HTML source—if you encrypt that, the user (and the browser) won't be able to read your content anymore.

If you want to protect your PHP source, then there are tools like Zend Guard. It would encrypt your source code and make it hard to reverse engineer.

If you want to protect your JavaScript, you can minify it with, for example, YUI Compressor. It won't prevent the user from using your code since, like the user, the browser needs to be able to read the code somehow, but at least it would make the task more difficult.

If you are more worried about user privacy, you should use SSL to make sure the sensitive information is encrypted when on the wire.

Finally, it is technically possible to encrypt the content of a page and use JavaScript to decrypt it, but since this relies on JavaScript, an experienced user could defeat this in a couple of minutes. Plus all these problems would appear:

  • Search engines won't be able to index your pages...
  • Users with JavaScript disabled would see the encrypted page
  • It could perform really poorly depending the amount of content you have

So I don't advise you to use this solution.

like image 148
RageZ Avatar answered Dec 17 '22 14:12

RageZ


You can't really disable that because eventually the browser will still need to read and parse the source in order to output.

If there is something SO important in your source code, I recommend you hide it on server side.

Even if you encrypt or obfuscate your HTML source, eventually we still can eval and view it. Using Firebug for instance, we can see source code no matter what.

If you are selling PHP software, you can consider Software as a Service (SaaS).

like image 42
mauris Avatar answered Dec 17 '22 12:12

mauris