Password protecting your pages


  1. EyeGuy
  2. ali_baba
  3. rashidBhuiya
  4. rashidBhuiya
  5. rashidBhuiya

This archived discussion is "read only".
For the corresponding "live" discussions, post in the active topic forum here.



Top 1.   Mar 24, 2000 12:14 PM

» EyeGuy - Javascript

Is there a way to script password protection without the use of .asp or .cgi and not making the userid and password available through view->source at the top of the browser?

-- posted by EyeGuy



Top 2.   Apr 7, 2000 12:54 PM

» ali_baba - Password Protecting HTML Pages

Password protecting a page using JavaScript is not recommended becauses this type of protection is merely an illusion. It's not a real protection technique. However, if you want to password protect a page on your personal home page, then JavaScript techniques may help you out. But remember, whatever protection mechanism you apply with JavaScript is easily breakable. The method I am going to explain doesn't show the password when you view the source code. But anyone having experience in a programming language can read this code for 5 minutes and easily break it.

The basic idea is to encode every input from the user and compare it with the encoded password. The password is alibaba, which is encoded as 65767366656665. Now, if you enter baab, the encoded message will be 66656566, which is not equal to the encoded password. The viewer of the html source cannot guess the original password by looking at 65767366656665. But somebody knowing programming can see the logic behind the code and generate the original password from the encoded number. Moreover, one can always see the URL pointed to by the password verifier and can directly type it in his browser window.

The code is given below only for educational purpose - don't base on it for real implementation:



<html>
<head>
<title>JavaScript Password Protection</title>
<script language="JavaScript">
<!-- Hiding from old browsers
function check_password (form)
   {
   var input = form.pass.value;
   encoded = "";
   for (i=0; i<input.length; i++)
      encoded += input.charCodeAt(i) - 32;
   // alert ("The encoding of your string is " + encoded);
   if (encoded == "65767366656665")
      alert ("You are allowed");
   else
      alert ("You are not allowed");
   }
// -->
</script>
</head>


<body>
<form name="verification">
Please enter the password below:
<input type="text" name="pass" size="10">
<input type="button" value="Enter!" onClick="check_password (verification)">
</form>
</body>
</html>

Please copy and paste this code in a blank html file and load it into your web browser to see how this works!

I am waiting for any further queries.

-- posted by ali_baba



Top 3.   Feb 25, 2003 3:54 PM

» rashidBhuiya - Re: Password Protecting HTML Pages

In response to message posted by ali_baba:

hey man..
how do i add a site to that page, you haven't said anything bout that. i want to had a normal page that has pictures in it. and i want it to block also the pages that is linked to this page i have with the password system, you have given. is it possible to do that?

-- posted by rashidBhuiya



Top 4.   Feb 25, 2003 3:54 PM

» rashidBhuiya - Re: Password Protecting HTML Pages

In response to message posted by ali_baba:

hey man..
how do i add a site to that page, you haven't said anything bout that. i want to had a normal page that has pictures in it. and i want it to block also the pages that is linked to this page i have with the password system, you have given. is it possible to do that?
if so how?

-- posted by rashidBhuiya



Top 5.   Feb 25, 2003 4:29 PM

» rashidBhuiya - Password Protecting HTML Pages

i have used your javascript, and tested it out. i now what it to show me the page after i enter the password. but i don't seem to know how. i'm not every well known with HTML, can you tell me how i can do that?

-- posted by rashidBhuiya



Please follow the guidelines set forth in the Suite101 Posting Etiquette when adding to the discussion.