How to hide the source code of a HTML page

Francis picture Francis · Aug 10, 2014 · Viewed 85.2k times · Source

I created an HTML page and now would like to hide the source code and encrypt it.

How can I do that?

Answer

Francis UK picture Francis UK · Aug 10, 2014

You can disable the right click, but that's a bad idea because expert minds can read anything from your page. You cannot totally hide the page source - this is not possible. Nothing is secure enough on the Internet.

In any case, you can encrypt it and set a password. You can utilise this link - it will encrypt your HTML page with a password.


First up, disable the right click, by writing out this script, right after the tag.

<SCRIPT language=JavaScript>

<!-- http://www.spacegun.co.uk -->

var message = "function disabled";

function rtclickcheck(keyp){ if (navigator.appName == "Netscape" && keyp.which == 3){ alert(message); return false; }

if (navigator.appVersion.indexOf("MSIE") != -1 && event.button == 2) { alert(message); return false; } }

document.onmousedown = rtclickcheck;

</SCRIPT>

Then, encrypt all of it, in this website, called 'AES encryption'.

Link - http://aesencryption.net/

You need to set a password to decrypt it ....you choose the password.

After encrypting it, you can just write a basic HTML page just putting into the <head> tag once again the script to disable the right click, into the <body> tag you code and hide everything just writing at top of the page <html hidden>.

Example

<!DOCTYPE html>
<html hidden>
<head>
<SCRIPT language=JavaScript>

<!-- http://www.spacegun.co.uk -->

var message = "function disabled";

function rtclickcheck(keyp){ if (navigator.appName == "Netscape" && keyp.which == 3){ alert(message); return false; }

if (navigator.appVersion.indexOf("MSIE") != -1 && event.button == 2) { alert(message); return false; } }

document.onmousedown = rtclickcheck;

</SCRIPT>
</head>
<body>
--here, you put the encrypted code from the link above--

</body>
</html>

Where it is written var message = "function disabled"; you can write for example something like 'This page cannot be viewed' or something which will annoy most of the users and will just leave. ['This page is unavailable' and so on ....].

Finally, you will see a blank page with a message coming up as soon as you right click the page. The message will be something like 'This page is no longer active'.

Example

  <SCRIPT language=JavaScript>

    <!-- http://www.spacegun.co.uk -->

    var message = "**This page is no longer active**";

    function rtclickcheck(keyp){ if (navigator.appName == "Netscape" && keyp.which == 3){ alert(message); return false; }

    if (navigator.appVersion.indexOf("MSIE") != -1 && event.button == 2) { alert(message); return false; } }

    document.onmousedown = rtclickcheck;

    </SCRIPT>

I do know that one can remove the <html hidden> or the Javascript script with some add-ons such as Firebug but anyway you will need to decrypt the code with a password in order to see the real page. Expert users might view the source code with a Brute Force attack, I think. So, nothing is safe.


I found out an application that you need to instal on your computer. There is a feature in the Enterprise version but you must pay to get it. This feature is a tool which encrypt your HTML page creating an ultra-strong password encryption for HTML files using up to 384 bit keys for encryption [the link I wrote above uses up to 256 bit keys for encryption]. I have never tried it out, though, because it is not for free.

Anyway, the link of the software 'HTML Guardian' - http://www.protware.com/default.htm For the feature about the encryption, merely click on 'Ultra-Strong HTML password protection' in the page.