public function generate(
        $type = self::PASSWORD_ALPHANUM_SPECIAL,
        $length = 12,
        $returnType = self::RETURN_TYPE_PLAIN
    ) {
        // empty pass
        $password = '';

        switch ($type) {
            case self::PASSWORD_ALPHANUM:
                // build password
                for ($i = 0; $i < $length; ++$i) {
                    $password .= $this->getRandomCharacter(self::$_RANGE_ALPHANUM['default']);
                }
                break;
            case self::PASSWORD_ALPHANUM_SPECIAL:
                // build password
                for ($i = 0; $i < $length; ++$i) {
                    $password .= $this->getRandomCharacter(self::$_RANGE_ALPHANUM_SPECIAL['default']);
                }
                break;
            case self::PASSWORD_ALPHANUM_SPECIAL_HARDCORE:
                // build password
                for ($i = 0; $i < $length; ++$i) {
                    $password .= $this->getRandomCharacter(self::$_RANGE_ALPHANUM_SPECIAL_HARDCORE['default']);
                }
                break;
            case self::PASSWORD_USERFRIENDLY:
                $password = $this->_createUserFriendlyPassword(self::$_RANGE_USERFRIENDLY, $length);
                break;
            case self::PASSWORD_USERFRIENDLY_REMEMBER:
                $password = $this->_createUserFriendlyPassword(self::$_RANGE_USERFRIENDLY_REMEMBER, $length);
                break;
        }

        // check for transformation of password to hash
        switch ($returnType) {
            case self::RETURN_TYPE_MD5:
                $password = $this->getMd5Hash($password);
                break;
            case self::RETURN_TYPE_PASSWORDHASH:
                $password = $this->getPasswordhash($password);
                break;
        }

        // return new created password
        return $password;
    }
public function generate(
        $type = self::PASSWORD_ALPHANUM_SPECIAL,
        $length = 12,
        $returnType = self::RETURN_TYPE_PLAIN
    ) {
        // empty pass
        $password = '';

        switch ($type) {
            case self::PASSWORD_ALPHANUM:
                // build password
                for ($i = 0; $i < $length; ++$i) {
                    $password .= $this->getRandomCharacter(self::$_RANGE_ALPHANUM['default']);
                }
                break;
            case self::PASSWORD_ALPHANUM_SPECIAL:
                // build password
                for ($i = 0; $i < $length; ++$i) {
                    $password .= $this->getRandomCharacter(self::$_RANGE_ALPHANUM_SPECIAL['default']);
                }
                break;
            case self::PASSWORD_ALPHANUM_SPECIAL_HARDCORE:
                // build password
                for ($i = 0; $i < $length; ++$i) {
                    $password .= $this->getRandomCharacter(self::$_RANGE_ALPHANUM_SPECIAL_HARDCORE['default']);
                }
                break;
            case self::PASSWORD_USERFRIENDLY:
                $password = $this->_createUserFriendlyPassword(self::$_RANGE_USERFRIENDLY, $length);
                break;
            case self::PASSWORD_USERFRIENDLY_REMEMBER:
                $password = $this->_createUserFriendlyPassword(self::$_RANGE_USERFRIENDLY_REMEMBER, $length);
                break;
        }

        // check for transformation of password to hash
        switch ($returnType) {
            case self::RETURN_TYPE_MD5:
                $password = $this->getMd5Hash($password);
                break;
            case self::RETURN_TYPE_PASSWORDHASH:
                $password = $this->getPasswordhash($password);
                break;
        }

        // return new created password
        return $password;
    }
public function generate ( $ type = self :: PASSWORD_ALPHANUM_SPECIAL , $ length = 12 , $ returnType = self :: RETURN_TYPE_PLAIN ) { // empty pass $ password = '' ; switch ( $ type ) { case self :: PASSWORD_ALPHANUM : // build password for ( $ i = 0 ; $ i < $ length ; ++ $ i ) { $ password .= $ this -> getRandomCharacter ( self :: $ _RANGE_ALPHANUM [ 'default' ] ) ; } break ; case self :: PASSWORD_ALPHANUM_SPECIAL : // build password for ( $ i = 0 ; $ i < $ length ; ++ $ i ) { $ password .= $ this -> getRandomCharacter ( self :: $ _RANGE_ALPHANUM_SPECIAL [ 'default' ] ) ; } break ; case self :: PASSWORD_ALPHANUM_SPECIAL_HARDCORE : // build password for ( $ i = 0 ; $ i < $ length ; ++ $ i ) { $ password .= $ this -> getRandomCharacter ( self :: $ _RANGE_ALPHANUM_SPECIAL_HARDCORE [ 'default' ] ) ; } break ; case self :: PASSWORD_USERFRIENDLY : $ password = $ this -> _createUserFriendlyPassword ( self :: $ _RANGE_USERFRIENDLY , $ length ) ; break ; case self :: PASSWORD_USERFRIENDLY_REMEMBER : $ password = $ this -> _createUserFriendlyPassword ( self :: $ _RANGE_USERFRIENDLY_REMEMBER , $ length ) ; break ; } // check for transformation of password to hash switch ( $ returnType ) { case self :: RETURN_TYPE_MD5 : $ password = $ this -> getMd5Hash ( $ password ) ; break ; case self :: RETURN_TYPE_PASSWORDHASH : $ password = $ this -> getPasswordhash ( $ password ) ; break ; } // return new created password return $ password ; }
generates a random password.

This method is intend to generate a random password.

@param int    $type       The type of the password to generate
@param int    $length     The length of the password to generate
@param string $returnType The return-type of the password to generate

@author Benjamin Carl <opensource@clickalicious.de>

@return string The new (random) generated password

@throws Doozr_Exception
generates a random password .