Greetings. I'm using the following code to auth logins. The problem is that I'm checking the passwords against a plain text name
assword file, with no encryption. The code here takes salt from the ENCRYPTED password to use to unencrypt it. Either that is wrong and it should take salt from the unencrypted password, or there is some way to make an encrypted password using salt from how it will end up, which seems impossible.
My problem is that I have no way to encrypt the passwords INTO the password list file that I know of, bar echo'ing the results of crypt(password,saltfromunencryptedpassword) and using this encrypted password using the unencrypted password as it's salt source, to gaina n encrypted password. Am I missing something? The guide I was looking at didn't mention about registering users or hwo to encrypt their passwords =/
Any help?
// iterate through file
foreach ($data as $line)
{
$arr = explode(":", $line);
// if username matches
// test password
if ($arr[0] == $user)
{
// get salt and crypt()
$salt = substr($arr[1], 0, 2);
// if match, user/pass combination is correct
// return 1
if ($arr[1] == crypt($pass, $salt))
{
$result = 1;
break;
}
// otherwise return 0
else
{
$result = 0;
break;
}
}
}
My problem is that I have no way to encrypt the passwords INTO the password list file that I know of, bar echo'ing the results of crypt(password,saltfromunencryptedpassword) and using this encrypted password using the unencrypted password as it's salt source, to gaina n encrypted password. Am I missing something? The guide I was looking at didn't mention about registering users or hwo to encrypt their passwords =/
Any help?
// iterate through file
foreach ($data as $line)
{
$arr = explode(":", $line);
// if username matches
// test password
if ($arr[0] == $user)
{
// get salt and crypt()
$salt = substr($arr[1], 0, 2);
// if match, user/pass combination is correct
// return 1
if ($arr[1] == crypt($pass, $salt))
{
$result = 1;
break;
}
// otherwise return 0
else
{
$result = 0;
break;
}
}
}