Password Protection3. Encrypted |
|
Join the DiscussionMore of this FeatureIf you encrypt your web page to try to hide your page source from your visitors then it becomes possible to include a very simple password protection javascript into the page itself that is a lot more effective and which you might even prefer to using a gateway CGI script. This method has the advantage over the other methods in that the password protection no longer acts just as a gate but will ensure that anyone accessing the page needs to enter the password even if they know the exact filename that they want to access. Also, unlike the above script, this one allows you to specify a page to be displayed if a wrong password (or no password) is entered. Also this script can be applied to existing pages without having to recode any of the links to the page. For this to work, you need to make sure that you encrypt the javascript before including it in the <head> section of the page so that people who know how to access the source of your page without viewing the page first can't easily discover the password. The password is then as secure as your page encryption, the encryption needs to be broken in order for the password to be determined. The rest of the page content also needs to be encrypted or it will be accessible by saving the page source even though the page itself is not viewable. To create your own custom script simply make substitutions into the following code for your desired password and for a page to display when a wrong password is entered (the two spots not shown in bold text), encrypt the result (including the script tags) and include the resultant encrypted code immediately after the decryptor script.
<script type="text/javascript">var
pw = prompt('Password',''); if (pw !=
'password') top.location =
'index.html';</script>
Your page will now display a prompt box asking to have the password entered before the actual page content is displayed. If the prompt box is closed, cancel is selected, or a wrong password is entered then the alternate page will be loaded into the browser and the current page will not be displayed. Note that the discussion and scripts on this page are copied from the "Ask Felgall" website with the permission of the copyright owner. |

