The following few lines creates a random password and puts it into and md5 encrypted format to be saved in joomla database. If you are using non-encrypted password you can just use the first part, or if you are using simple md5 encryption and not looking for key:salt as joomla then you can simply take the $key from first part and encrypt it using the md5 function and store that. :)
$key = "";
srand((double)microtime() * rand(1000, 9999));
$charset = "abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ0123456789";
for($len=0; $len<8; $len++)
$key .= $charset[rand(0, strlen($charset)-1)];
//End of part 1, you will have a simple random password here in $key
$salt = JUserHelper::genRandomPassword(32);
$crypt = JUserHelper::getCryptedPassword($key, $salt);
$password = $crypt . ':' . $salt;
$password will have the value that you can save into database in users table.
$key = "";
srand((double)microtime() * rand(1000, 9999));
$charset = "abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ0123456789";
for($len=0; $len<8; $len++)
$key .= $charset[rand(0, strlen($charset)-1)];
//End of part 1, you will have a simple random password here in $key
$salt = JUserHelper::genRandomPassword(32);
$crypt = JUserHelper::getCryptedPassword($key, $salt);
$password = $crypt . ':' . $salt;
$password will have the value that you can save into database in users table.
No comments:
Post a Comment