Click to See Complete Forum and Search --> : password protected area script help


colourcube
05-21-2003, 03:12 PM
Hi everyone,

I'm a fresh web designer and I'm trying to put up my portfolio web site, but there is a section on the site that I don't want people to access without a password. I found this free script but it seems to show the password right in the script when you view the source. It there any way to hide the password? Any help would be appreciated. Thanks!

<SCRIPT LANGUAGE="JavaScript">
function LogIn(){
loggedin=false;
username="";
password="";
username=prompt("Username:","");
username=username.toLowerCase();
password=prompt("Password:","");
password=password.toLowerCase();
if (username=="guest" && password=="login") {
loggedin=true;
window.location="home-page.html";
}
if (username=="guest2" && password=="login2") {
loggedin=true;
window.location="secure.html";
}
if (loggedin==false) {
alert("Invalid login!");
}
}
</SCRIPT>

pyro
05-21-2003, 03:23 PM
You should use server side programming to do this. Javascript passwords are not even the least bit secure. Try posting in one of our server side areas to get some help creating a much more secure one. PHP (http://forums.webdeveloper.com/forumdisplay.php?s=&forumid=16) (my personal favorite), CGI (http://forums.webdeveloper.com/forumdisplay.php?s=&forumid=4), or ASP (http://forums.webdeveloper.com/forumdisplay.php?s=&forumid=9)

colourcube
05-21-2003, 03:29 PM
cool thanks!

David Harrison
05-21-2003, 04:09 PM
Or you could use a numeric password and pass it through a series of logarithms powers and perhaps rearrange the numbers in it every so often but it will take a while for you to do and for somone with enough time and a little js knowledge could probably crack it.
On the upside you would have to bother learning any server-side code.

pyro
05-21-2003, 05:06 PM
Originally posted by lavalamp
On the upsideUnfortunately, the downside far out-weighs this. If one uses javascript for the password, even using "a series of logarithms powers" or "rearrange the numbers in it every so often", javascript passwords are quite easy to break, and leave you nothing, save a false sense of security.