Log in

View Full Version : Password encryption using vb3 md5.js


*****Sniper
05-12-2004, 01:25 PM
I have successfully imported all forums and moderators from my old forum to vb3.
right now tho the moderators have an empty password field. reason being: not sure how to encrypt the password for vbulletin to understand!

so, in my password.php script I get the userid and password from my old database, store them in an array, and then what?

Is it possible to call the vbulletin_md5.js from a .php script and use it?
how do i use it? is it simply
$result = md5hash($myPassword[], $resultPassword)
[in the md5.js file is says "usage: md5hash(input, ouput)]
but then what about the 'salt' I have no idea how to go about doing this!
please help!

*****Sniper
05-12-2004, 02:18 PM
I see noone can help... give more hints maybe!

I have done this...

included the md5.js file in my script,
I copied in my script the function which creates the Salt in variable $Salt

took the password from a user which was 'hello' (it wasnt really but lets pretend)
>$oldPassword = 'hello'
I then did
>$password = md5 ($oldPassword . Salt);
This actually seems to work, it returned something like
$password = f6cdf703fa4faefd99ab85d25d5f0448
$Salt = G<)

but, then i cut and paste these values in the database (password and salt field) wnd when i tried to login it gave me 'wrong username or password' error.
what am I doing wrong?

Brad
05-12-2004, 03:11 PM
This should work, asuming the passwords are plan text in the old database:


require_once('./includes/functions_user.php');
$salt = fetch_user_salt();
$password = md5(md5($user['password']) . $salt);

*****Sniper
05-13-2004, 07:33 AM
Yes it does work, thank you!

linuxguy
02-22-2006, 02:46 PM
Yes it does work, thank you!

And if you're doing it at the SQL level:

UPDATE vbuser SET salt = '000';
UPDATE vbuser SET password = MD5(CONCAT(MD5(old_cleartext_password), salt));

That will do your entire table in one shot. Obviously replace old_cleartext_password with whatever field from whatever table it is that has the passwords.