using php to create a joomla user password?

SoulieBaby picture SoulieBaby · Apr 28, 2010 · Viewed 18.6k times · Source

I'm trying to create a custom registration component for Joomla, and I was wondering if anyone knew how to create the correct password encryption for joomla? Joomla passwords look like this :

fbae378704687625a410223a61c66eb1:VM6DwmVWHTwpquDq51ZXjWWADCIc93MR

Which I believe are md5 (or something) and one way encryption? Am just looking for a php code of sorts to create that same encryption.

Cheers

Answer

SoulieBaby picture SoulieBaby · Apr 28, 2010
$salt = JUserHelper::genRandomPassword(32);
$crypt = JUserHelper::getCryptedPassword("yourpassword", $salt);
$password = $crypt.':'.$salt;

After a bit more searching i found my answer, thanks guys for your help :)

EDIT: I forgot to mention that you need to include this line before calling JUserHelper:

jimport('joomla.user.helper');