I am trying to find a simple script that will require members to log into a page using a username and password, but one where they can't just view the page source to find it. [sig][/sig]
use server side code
html,css,javsscript are some of the BROWSERSIDE code
perl,php,c++,java are some of the SERVERSIDE code someone knowledge ends were
someone else knowledge starts
thread216-251963 can show you why depending on JavaScript only is futile efforts that will not stop someone to access your "protected" pages.
Try server side technology such as PHP can to make a simple password check. Attempting to do this in JavaScript or any combination of source hidding code is NOT worth the effort.
Anyone in the top ten experts of this post will be able in less than a minute to access your "hidden" area.
PHP is relatively easy to learn for someone that knows javascript. Gary
offers a very good FREE version, it can be a little awkward to get it set up but its a very good script IMHO.
I have a good java version which is "fairly" secure but dont use it for anything 'sensitive'. And you have to set up the users yourself, theres no registration script with it.
let me know if u want it.
One thing I've done for quite a while, and have seen described as secure in Javascript as possible, is to run passwords and login names through a math formula, like creating a one way hash. Since those numbers can't be reverse engineered to find out the password, the only method to find the password is brute force then. Those numbers can be stored in Javascript that's visible, and even showing the algorithm. The basic formula is something like this:
function createnum(wordstring)
{
var mult = 1, checknum=0;
for (var wi=0;wi<wordstring.length;wi++)
{
var onenum = wordstring.charCodeAt(wi) * mult;
checknum += onenum;
mult *= 3;
}
return checknum;
}
The following is the exact script I've used to get sums of passwords. Login names can be done the same way. The sums are stored either in 2 arrays then, or in an array of objects with the login sum as one property and the password sum as the other, on the HTML page or Javascript. This array can be listed on the page without showing the password or login names. The only thing that can break this algorithm is brute force, though with some experimentation and understanding of the code, certain ranges of passwords can be ruled out. The longer the string used, the more difficult it would be to crack with brute force, too.
The same function can be used, with the string value sent as a parameter to the function, and then compared to the list of allowed numbers generated. Strings are case sensitive here, and any keyboard character.
I saw a similar algorithm on a Javascript download site (like Javascript.com, or one of the others) a couple years ago that listed it as unbreakable and rated highly, but it was limted to alphanumeric characters only. I've used a similar algorithm for a long time for validating passwords and storing login names, and in 17 bytes store login name, password, and access level information for each user.
<script language="javascript">
function doencrypt()
{
var onepass=document.password.clear.value;
var passSum=0, mult=1;
for (var pi=0;pi<onepass.length;pi++)
{
var onenumber=onepass.charCodeAt(pi);
passSum += onenumber * mult;
mult *= 3;
}
document.password.encrypted.value = passSum;
}
</script>
This function would be used to check passwords against the numbers on the list on the login page.
<script language="javascript">
//these numbers were generated from passwords from the previous function
var passarray = new Array(1234, 7465, 98674);
function checkencrypt(onestring)
{
var onepass=onestring;
var passSum=0, mult=1;
for (var pi=0;pi<onepass.length;pi++)
{
var onenumber=onepass.charCodeAt(pi);
passSum += onenumber * mult;
mult *= 3;
}
for (var pi=0;pi<passarray.length;pi++)
{
if (passSum == passarray[pi]) return true;
}
return false;
}
</script>
I feel I should put my two-cents into this post. If you have a hosting company then 99% of time they provide some kind of server-type abilities.
Ask your hosting company what you need and they will suggest the best (and economical) solution. But everyone here is right, you need a server-side coding, like ASP, Coldfusion, CGI, etc. Any other method is dangerious and unsafe, especially when you have sensitive customer information.
I have this little thing, Advanced Delusionary Schizophrenia with Involuntary Narcissistic Rage.
It's no big deal really...
the hashing idea seems a decent solution check for basic login using only javascript.
The only thing is, if you are doing this client-side there's nothing stopping anyone from doing view-source and finding the 'logged in' target page (and then just going there directly).
So, IMO it's a waste of time going to all the trouble of hashing because you still can't hide the target page. (Janet24 that link also uses hashing - and hides the logged in page using a bit of confusing code. It's a decent solution, but it isn't secure.)
My basic point is: Client-side scripting alone cannot provide secure password protection.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.