How to disable or encrypt “View Source” for my site

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

Answers:

Answer

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.

Answer

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

Answer

So you want to encrypt your HTML source. You can encrypt it using some javascript tool, but beware that if the user is smart enough, he will always be able to decrypt it doing the same thing that the browser should do: run the javascript and see the generated HTML.

EDIT: See this HTML scrambler as an example on how to encrypt it: http://www.voormedia.com/en/tools/html-obfuscate-scrambler.php

EDIT2: And .. see this one for how to decrypt it :)

http://www.gooby.ca/decrypt/

Answer

Short answer is not, html is an open text format what ever you do if the page renders people will be able to see your source code. You can use javascript to disable the right click which will work on some browsers but any one wanting to use your code will know how to avoid this. You can also have javascrpit emit the html after storing this encoded, this will have bad impacts on development, accessibility, and speed of load. After all that any one with firebug installed will still be able to see you html code.

There is also very really a lot of value in your html, your real ip is in your server code which stays safe and sound on your server.

Answer

This is fundamentally impossible. As (almost) everybody has said, the web browser of your user needs to be able to read your html and Javascript, and browsers exist to serve their users -- not you.

What this means is that no matter what you do there is eventually going to be something on a user's machine that looks like:

<html> 
  <body> 
    <div id="my secret page layout trick"> ... 
    </div>
  </body>
</html>

because otherwise there is nothing to show the user. If that exists on the client-side, then you have lost control of it. Even if you managed to convince every browser-maker on the planet to not make that available through a "view source" option -- which is, you know, unlikely -- the text will still exist on that user's machine, and somebody will figure out how to get to it. And that will never happen, browsers will always exist to serve their users before all others. (Hopefully)

The same thing is true for all of your Javascript. Let me say it again: nothing that you send to a user is secure or secret from that user. The encryption via Javascript hack is stupid and cannot work in any meaningful sense.

(Well, actually, Flash and Silverlight ship binaries, but I don't think that they're encrypted. So they are at the least irritating to get data out of.)

As others have said, the only way to keep something secret from your users is to not give it to them: put the logic in your server and make sure that it is never sent. For example, all of the code that you write in PHP (or Python/Ruby/Perl/Java/C...) should never be seen by your users. This is e.g. why Google still has a business. What they give you is fundamentally uninteresting compared to what they never send to you. And, because they realize this, they try to make most things that they send you as open as useful as possible. Because it's the infrastructure -- the Terrabyte-huge maps database and pathfinding software, as opposed to the snazzy map that you can click and drag -- that you are trading your privacy for.

Another example: I'm not sure if you remember how many tricks people employed in the early days of the web to try and keep people from saving images to disk. When was the last time you ran across one of those? Know why? Because once data is on your user's machine, she controls it. Not you.

So, in short: if you want to keep something secret from your user, don't give it to her.

Answer

You cant. The browser needs the source to render the page. If the user user wishes the user may have the browser show the source. Firefox can also show you the DOM of the page. You can obfuscate the source but not encrypt or lock the user out.

Also why would you want this, it seem like a lame ass thing to do :P

Answer

I don't think there is a way to do this. Because if you encrypt how the browser will understand the HTML?

Answer

No. The browsers offer no ability for the HTML/javascript to disable that feature (thankfully). Plus even if you could the HTML is still transmitted in plain text ready for a HTTP sniffer to read.

Best you could do would be to somehow obscure the HTML/javascript to make it hard to read. But then debuggers like Firebug and IE 8's debugger will reconstruct it from the DOM making it easy to read,

Answer

You can, in fact, disable the right click function. It is useless to do so, however, as most browsers now have built in inspector tools which show the source anyway. Not to mention that other workarounds (such as saving the page, then opening the source, or simply using hotkeys) exist for viewing the html source. Tutorials for disabling the right click function abound across the web, so a quick google search will point you in the right direction if you fell an overwhelming urge to waste your time.

Answer

There is no full proof way.

But You can fool many people using simple Hack using below methods:

"window.history.pushState()" and adding oncontextmenu="return false" in body tag as attribute

Detail here - http://freelancer.usercv.com/blog/28/hide-website-source-code-in-view-source-using-stupid-one-line-chinese-hack-code

You can also use “javascript obfuscation” to further complicate things, but it won’t hide it completely.

Inspect Element” can reveal everything beyond view-source.

Answer

Yes, you can have your whole website being rendered dynamically via javascript which would be encrypted/packed/obfuscated like there is no tomorrow.

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.