PDA

View Full Version : Password Hash


travisneids
02-21-2012, 05:16 PM
I've done my research but for the life of me, I can not replicate what vBulletin is doing! I'm creating a user from another website which duplicates what is needed in the vBulletin table but I still can't login with these users! Code follows:

private function fetch_user_salt($length = 30) {
$salt = '';
for ($i = 0; $i < $length; $i++) {
$salt .= chr(rand(33, 126));
}
return mysql_real_escape_string($salt);
}

public function vbPassword($clearPassword) {
$object = new stdClass();
$vb_salt = self::fetch_user_salt();
$password_salted = md5(md5($clearPassword) . $vb_salt);
$object->salt = $vb_salt;
$object->password_salted = $password_salted;
return $object;
}

My database saves the following:
$object->salt INTO salt column
$object->password_salted INTO password column

Am I missing a step? Another crazy ass MD5 or something? I feel like I should be able to login from the forums now.

Thank you!

kh99
02-21-2012, 05:19 PM
Oops...never mind, I was looking at the wrong code. :o

travisneids
02-21-2012, 05:19 PM
I'm an idiot - my random number is too long!!! It should only be three letters! Bah.