Hi. I've got a good login page running but I decided I needed to encrypt the passwords. When adding a new user mhash works fine
here's what I do:
$the_hash = MHASH_TIGER;
$thehashentry = mhash($the_hash , $pass1);
$theentry = "\r".$userid.":".bin2hex($thehashentry)."--";
$thefile = fopen("logins.txt" , 'a');
fwrite($thefile , $theentry);
fclose($thefile);
my problem is that when I try and check the user entered password against the file it won't match. Here's what I'm doing for that:
$userid = $POST["login"];
$passwd = $POST["passw"];
$thehash = MHASH_TIGER;
$hashedpass = mhash($thehash , $passwd);
$line = explode("--" , $buffer);
$i = 0;
$thecheck =0;
while($i < sizeof($line))
{
$datapair = explode(":" , trim($line[$i]));
if(($datapair[0] == $userid and $datapair[1] == bin2hex($hashedpass)))
{
$thecheck = 1;
break;
}
It's probably something little and simple but it's beyond me. Any insight is appreciated.