API15

JUserHelper/genRandomPassword

< API15:JUserHelper

The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description

Generate a random password

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax

genRandomPassword($length=8)
Parameter Name Default Value Description
$length 8 $length Length of the password to generate

Returns

string Random Password

Defined in

libraries/joomla/user/helper.php

Importing

jimport( 'joomla.user.helper' );

Source Body

function genRandomPassword($length = 8)
{
        $salt = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        $len = strlen($salt);
        $makepass = '';

        $stat = @stat(__FILE__);
        if(empty($stat) || !is_array($stat)) $stat = array(php_uname());

        mt_srand(crc32(microtime() . implode('|', $stat)));

        for ($i = 0; $i < $length; $i ++) {
                $makepass .= $salt[mt_rand(0, $len -1)];
        }

        return $makepass;
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples

Code Examples


Advertisement