src/Alg/Randomizer.php
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.' );
	}
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.' );
	}
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.' ) ; }
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
Builds and returns randomized string .