/    Sign up×
Community /Pin to ProfileBookmark

password protected area script help

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>

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@pyroMay 21.2003 — 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. [URL=http://forums.webdeveloper.com/forumdisplay.php?s=&forumid=16]PHP[/URL] (my personal favorite), [URL=http://forums.webdeveloper.com/forumdisplay.php?s=&forumid=4]CGI[/URL], or [URL=http://forums.webdeveloper.com/forumdisplay.php?s=&forumid=9]ASP[/URL]
Copy linkTweet thisAlerts:
@colourcubeauthorMay 21.2003 — cool thanks!
Copy linkTweet thisAlerts:
@David_HarrisonMay 21.2003 — 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.
Copy linkTweet thisAlerts:
@pyroMay 21.2003 — [i]Originally posted by lavalamp [/i]

[B]On the upside[/B][/QUOTE]
Unfortunately, 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.
×

Success!

Help @colourcube spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...