src/classes/CCStr.php
public static function random( $length = 25, $charset = null ) 
	{
		$charset = static::charset( $charset );

		$count = strlen( $charset ); $string = '';

		while ( $length-- ) 
		{
			$string .= $charset[mt_rand(0, $count-1)];
		}

		return $string;
	}
public static function random( $length = 25, $charset = null ) 
	{
		$charset = static::charset( $charset );

		$count = strlen( $charset ); $string = '';

		while ( $length-- ) 
		{
			$string .= $charset[mt_rand(0, $count-1)];
		}

		return $string;
	}
public static function random ( $ length = 25 , $ charset = null ) { $ charset = static :: charset ( $ charset ) ; $ count = strlen ( $ charset ) ; $ string = '' ; while ( $ length -- ) { $ string .= $ charset [ mt_rand ( 0 , $ count - 1 ) ] ; } return $ string ; }
Generate a random string with the given length and charset.

CCStr::random( 8, 'hex' ); // 56F6AE10
CCStr::random( 4, 'password' ); // ?F%7

@param int		$length		Default is 25
@param string		$charset		This parameter uses the CCStr::charset function
@return string
Generate a random string with the given length and charset .