Search code examples
phppasswordsjoomla2.5

What is Joomla 2.5 Password Encryption method?


I'm developing a web site using Joomla 2.5. I have Included another sample site for the above parent site. from this child site I'm gonna add new users to the database. but these two sites are uses different method to password encryption.

I found something on web as Joomla encryption but it seems to be not working.

function genRandomPassword($length=32) 
{
$salt       = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$makepass   = '';
mt_srand(10000000*(double)microtime());
for ($i = 0; $i < $length; $i++)
    $makepass .= $salt[mt_rand(0,61)];
return $makepass;
}

    if ( strlen($_POST['pwd']) > 100 )
    {
        $_POST['pwd'] = substr( $_POST['pwd'], 0, 100 );
    }

    $salt = genRandomPassword();
    $pass= md5(stripslashes($_POST['pwd']).$salt) .':'.$salt;

Isn't this the method or where am I doing wrong?

Thank you


Solution

  • Finally found the way; thinks this will help someone else :)

        if ( strlen($_POST['pwd']) > 100 )
         {
            $_POST['pwd'] = substr( $_POST['pwd'], 0, 100 );
         }
    
         $salt = genRandomPassword();
        //$pass is the encripted password
         $pass= md5(stripslashes($_POST['pwd']).$salt) .':'.$salt;
    

    Hash generation as follows:

        function genRandomPassword($length = 32)
        {
         $salt = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
         $len = strlen($salt);
         $makepass = '';
         mt_srand(10000000 * (double) microtime());
    
         for ($i = 0; $i < $length; $i ++) {
            $makepass .= $salt[mt_rand(0, $len -1)];
         }
    
         return $makepass;
        }