Joomla – Generar contraseñas de usuarios en php

Funciones para generar password de usuarios en cms Joomla en php.
function mosMakePassword($length=8) {
   $salt = “abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789″;
   $makepass = ”;
   mt_srand(10000000*(double)microtime());
   for ($i = 0; $i < $length; $i++)
      $makepass .= $salt[mt_rand(0,61)];
   return $makepass;
}

function josHashPassword($password)
{
   $salt = mosMakePassword(16);
   $crypt = md5($password.$salt);
   $hash = $crypt.’:’.$salt;

   return $hash;
}

$password_nueva = josHashPassword($password);