ID:140666
 
Code:
mob
var
pass
username
upass
mpass
Login()
..()
Lbl
switch(input("Choose option:", "Create Account") in list("Create Account", "Login"))
if("Login")
username = input("Username:", "Guest", username)
if (fexists("saves/[copytext(ckey(username),1,2)]/[ckey(username)].sav"))
var/savefile/si = new("saves/[copytext(ckey(username),1,2)]/[ckey(username)].sav")
si["password"] >> pass
upass = input("Password:", "Guest", upass)
mpass = md5(upass)
if(mpass == pass)
alert("Login accepted")
//Continue with your regular stuff here.
else
alert("Error: Invalid user/pass combonation")
goto Lbl
else
alert("Error: Username doesn't exsist!")
goto Lbl
if("Create Account")
username = input("Username:", "Username", username)
var/savefile/si = new("saves/[copytext(ckey(username),1,2)]/[ckey(username)].sav")
pass = input("Password:", "Password", pass)
upass = md5(pass)
si["password"] << upass
goto Lbl


Problem description:
I am trying to make a login system for use with dmb2exe. However, for some odd reason the hashing does not appear to be working.
You are comparing a hashed value to an unhashed value.
In response to Garthor
i am?

It appears to work, but you have to register twice. When i opened the savefile i found that it had 2 values, . = hashedpasss & password = hashedpass (replace hashedpass with the hash)

Can anyone tell me why this is?
In response to Neos300
Bump.

It's been a couple days, so i thought i would bump this.
In response to Neos300
You need to be more specific about what, exactly, happens.
In response to Garthor
Ok....

To create an account with this system, you must fill out the create account form 2 times, or it will not work. The first time you do it, it will create an unopenable savefile that is 0 bytes. The second time you do it, you can open the save file, and the file has 2 fields in it: . & password. What i want is so that you can create your account only once and it will still work.
In response to Neos300
Oh, I guess the problem was just a bit of an error on BYOND's part with variables going out-of-scope. The savefile doesn't get closed. You need to put "F = null" after you are done with the savefile if you are anticipating you may be creating a new savefile object that points to the same file.