Builds and returns randomized string.
@access		public
@param		int			$length			Length of String to build
@param		int			$strength		Strength to have at least (-100 <= x <= 100)
@return		string
195499
public function get( $length, $strength = 0 )
	{
		if( !is_int( $length ) )															//  Length is not Integer
			throw new InvalidArgumentException( 'Length must be an Integer.' );
		if( !$length )																		//  Length is 0
			throw new InvalidArgumentException( 'Length must greater than 0.' );
		if( !is_int( $strength ) )															//  Stength is not Integer
			throw new InvalidArgumentException( 'Strength must be an Integer.' );
		if( $strength && $strength > 100 )													//  Strength is to high
			throw new InvalidArgumentException( 'Strength must be at most 100.' );
		if( $strength && $strength < -100 )													//  Strength is to low
			throw new InvalidArgumentException( 'Strength must be at leastt -100.' );

		$length	= abs( $length );															//  absolute Length
		$pool	= $this->createPool();														//  create Sign Pool
		if( !strlen( $pool ) )																//  Pool is empty
			throw new RuntimeException( 'No usable signs defined.' );
		if( $this->unique && $length >= strlen( $pool ) )									//  Pool is smaller than Length
			throw new UnderflowException( 'Length must be lower than Number of usable Signs in "unique" Mode.' );

		$random	= $this->createString( $length, $pool );									//  randomize String
		if( !$strength )																	//  no Strength needed
			return $random;

		$turn	= 0;
		do
		{
			$currentStrength	= Alg_Crypt_PasswordStrength::getStrength( $random );		//  calculate Strength of random String
			if( $currentStrength >= $strength )												//  random String is strong enough
				return $random;
			$random	= $this->createString( $length, $pool );								//  randomize again
			$turn++;																		//  count turn
		}
		while( $turn < $this->maxTurns );													//  break if to much turns
		throw new RuntimeException( 'Strength Score '.$strength.' not reached after '.$turn.' Turns.' );
	}
953573
public function fwrite($string, $length = null)
    {
        return fwrite($this->handle, $string, (is_null($length) ? strlen($string) : $length));
    }
1232624
public static function GenerateRandomString(int $length = 20)
    {
        $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
        $charactersLength = strlen($characters);
        $randomString = '';
        for ($i = 0; $i < $length; $i++) {
            $randomString .= $characters[rand(0, $charactersLength - 1)];
        }
        return $randomString;
    }
529584
public static function createRandomAlphaNumeric($length = 8)
    {
        $chars  = array("abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", "123456789");
        $count  = array((strlen($chars[0]) - 1), (strlen($chars[1]) - 1));
        $prefix = "";
        for ($i = 0; $i < $length; $i++) {
            $type = mt_rand(0, 1);
            $prefix .= substr($chars[$type], mt_rand(0, $count[$type]), 1);
        }
        return self::create($prefix);
    }
215039
public static function getRandomString(int $length): string {
		
		// list of available chars for random string
		$availableChars = '123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVXYWZ';
		
		// create a random string
		return substr(str_shuffle($availableChars . $availableChars), 0, $length);
		
	}
1146271
public function generateSecret($length = 10)
	{
		$strong_secret = false;

		// Try to get $crypto_strong to evaluate to true. Give it 5 tries.
		for ($i = 0; $i < 5; $i++)
		{
			$secret = openssl_random_pseudo_bytes($length, $strong_secret);

			if ($strong_secret === true)
			{
				return $this->base32->encode($secret);
			}
		}

		return '';
	}
107398
protected function generateHash($length)
    {
        $token = '';
        for ($i = 0; $i < $length; ++ $i) {
            $rand = mt_rand(0, 35);
            
            if ($rand < 26) {
                $char = chr(ord('a') + $rand);
            } else {
                $char = chr(ord('0') + $rand - 26);
            }
            
            $token .= $char;
        }
        return $token;
    }
773025
public function genRandomPassword($length = 8) {

        $salt     = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        $base     = strlen($salt);
        $makepass = '';

        /*
         * Start with a cryptographic strength random string, then convert it to
         * a string with the numeric base of the salt.
         * Shift the base conversion on each character so the character
         * distribution is even, and randomize the start shift so it's not
         * predictable.
         */
        $random = Crypt::genRandomBytes($length + 1);
        $shift  = ord($random[0]);

        for ($i = 1; $i <= $length; ++$i) {
            $makepass .= $salt[($shift + ord($random[$i])) % $base];
            $shift += ord($random[$i]);
        }

        return $makepass;
    }
1078518
static function getRandomString($length = 8)
    {

        $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';

        $value = '';
        $charsLength = strlen($chars) - 1;

        for ($i = 1 ; $i <= $length; $i++) {
            $value .= $chars[rand(0, $charsLength)];
        }

        return $value;

    }
377901
protected static function rand($chars, $length)
    {
        $string = '';
        $max    = static::len($chars) - 1;
        $i      = 0;

        while ($i < $length)
        {
            $string .= $chars[Num::randomInt(0, $max)];
            $i++;
        }

        return $string;
    }
5996
public static function generate_pin($length = 8)
    {
        $factory = new \RandomLib\Factory;
        $generator = $factory->getLowStrengthGenerator();
        #--with easy to speak letters
        #$alfabet = range('A', 'Z');
        #$consonants = array_diff($alfabet, array('Y', 'H', 'W', 'Q', 'C')) ;
        #$chars = implode('',$consonants);
        #--full
        #$chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-#';
        #--only numbers
        $chars = '0123456789';
        $randomString = $generator->generateString($length, $chars);
        return $randomString;
    }
829385
public function generateRandomString(
        int $length = 10,
        string $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!#%^*()-_[]{}<>=/|$'
    ): string {
        $randomStr = '';
        for ($i = 0; $i < $length; $i++) {
            $randomCharIndex = random_int(0, \strlen($chars) - 1);
            $randomStr .= $chars[$randomCharIndex];
        }

        return $randomStr;
    }
659547
public function generate($length)
    {
        $realPool = $this->mergePools($this->characterPools);
        $max = (count($realPool) - 1);
        mt_srand();

        $randomString = '';

        for ($i = 0; $i < $length; $i++) {
            $randomString .= $realPool[mt_rand(0, $max)];
        }

        return $randomString;
    }
862458
public function generateRandomString($length)
    {
        do {
            $bytes = base64_encode($this->random->nextBytes($length));
            $string = substr(strtr($bytes, array('+' => '', '/' => '', '=' => '')), 0, $length);
        } while (strlen($string) < $length);
        return $string;
    }
1268348
protected function randomKey($length)
    {
        $string = '';
        while (($len = mb_strlen($string)) < $length) {
            $size = $length - $len;
            $bytes = random_bytes($size);
            $string .= mb_substr(str_replace(['\\', '/', '"', '\''], '', base64_encode($bytes)), 0, $size, 'UTF-8');
        }
        return $string;
    }
976860
public static function randomBytes($length = 16)
    {
        if (function_exists('random_bytes')) {
            $bytes = random_bytes($length);
        } elseif (function_exists('openssl_random_pseudo_bytes')) {
            $bytes = openssl_random_pseudo_bytes($length, $strong);
            if (false === $bytes || false === $strong) {
                throw new RuntimeException('Unable to generate random string.');
            }
        } else {
            throw new RuntimeException('OpenSSL extension is required for PHP 5 users.');
        }

        return $bytes;
    }
113488
public static function random( $length = 16 )
    {
        if ( function_exists( 'openssl_random_pseudo_bytes' ) )
        {
            $bytes = openssl_random_pseudo_bytes( $length * 2 );

            if ( FALSE === $bytes )
            {
                throw new RuntimeException( 'Unable to generate random string.' );
            }

            return substr( str_replace( [ '/', '+', '=' ], '', base64_encode( $bytes ) ), 0, $length );
        }

        return static::quickRandom( $length );
    }