framework/base/Security.php
public function generateRandomString($length = 32)
    {
        if (!is_int($length)) {
            throw new InvalidArgumentException('First parameter ($length) must be an integer');
        }

        if ($length < 1) {
            throw new InvalidArgumentException('First parameter ($length) must be greater than 0');
        }

        $bytes = $this->generateRandomKey($length);
        return substr(StringHelper::base64UrlEncode($bytes), 0, $length);
    }
public function generateRandomString($length = 32)
    {
        if (!is_int($length)) {
            throw new InvalidArgumentException('First parameter ($length) must be an integer');
        }

        if ($length < 1) {
            throw new InvalidArgumentException('First parameter ($length) must be greater than 0');
        }

        $bytes = $this->generateRandomKey($length);
        return substr(StringHelper::base64UrlEncode($bytes), 0, $length);
    }
public function generateRandomString ( $ length = 32 ) { if ( ! is_int ( $ length ) ) { throw new InvalidArgumentException ( 'First parameter ($length) must be an integer' ) ; } if ( $ length < 1 ) { throw new InvalidArgumentException ( 'First parameter ($length) must be greater than 0' ) ; } $ bytes = $ this -> generateRandomKey ( $ length ) ; return substr ( StringHelper :: base64UrlEncode ( $ bytes ) , 0 , $ length ) ; }
Generates a random string of specified length.
The string generated matches [A-Za-z0-9_-]+ and is transparent to URL-encoding.

@param int $length the length of the key in characters
@return string the generated random key
@throws Exception on failure.
Generates a random string of specified length . The string generated matches [ A - Za - z0 - 9_ - ] + and is transparent to URL - encoding .