Creating G2 hashed passwords

kliver

Joined: 2006-07-11
Posts: 1
Posted: Tue, 2006-07-11 10:29

I got a site with users in a database, clear text passwords.
I would like to insert (and synchronize) these users into G2.

I understand that the hashing algorithm for G2 is the following:

Quote:
function md5Salt($password, $salt='') {
if (empty($salt)) {
for ($i = 0; $i < 4; $i++) {
$char = mt_rand(48, 109);
$char += ($char > 90) ? 13 : ($char > 57) ? 7 : 0;
$salt .= chr($char);
}
} else {
$salt = substr($salt, 0, 4);
}
return $salt . md5($salt . $password);
}

therefore I wrote a little script, changing my user passwords into G2-hashed passwords:

Quote:
while (list($db_id,$db_vorname,$db_nachname,$db_cerevis,$db_email,$db_passwort) = mysql_fetch_row( $result_liste )) {

$full_name = "$db_vorname $db_nachname";

for ($i = 0; $i < 4; $i++) {
$char = mt_rand(48, 109);
$char += ($char > 90) ? 13 : ($char > 57) ? 7 : 0;
$salt .= chr($char);
}

$enc_pw = $salt . md5($salt . $db_passwort);
$salt ='';
}

if I manually copy $enc_pw into the table g2_user and try to login, it tells me that i would have provided the wrong password...

What is wrong?

 
ragedigital

Joined: 2007-03-07
Posts: 5
Posted: Wed, 2007-03-07 16:15

Got it - works perfectly!

Thanks,

darrin

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2007-03-07 15:28