src/Random.php
protected static function getRandomData($length, $packSize, $packFormat, $callback = null)
    {
		$data = '';
		while(strlen($data) < $length) {
			$randomBytes = self::getRandomBytes($packSize);
			$value = unpack($packFormat, $randomBytes)[1];
			if (is_callable($callback)) {
				$value = call_user_func($callback, $value);
			}
			$data .= $value;
		}
		return substr($data, 0, $length);
	}
protected static function getRandomData($length, $packSize, $packFormat, $callback = null)
    {
		$data = '';
		while(strlen($data) < $length) {
			$randomBytes = self::getRandomBytes($packSize);
			$value = unpack($packFormat, $randomBytes)[1];
			if (is_callable($callback)) {
				$value = call_user_func($callback, $value);
			}
			$data .= $value;
		}
		return substr($data, 0, $length);
	}
protected static function getRandomData ( $ length , $ packSize , $ packFormat , $ callback = null ) { $ data = '' ; while ( strlen ( $ data ) < $ length ) { $ randomBytes = self :: getRandomBytes ( $ packSize ) ; $ value = unpack ( $ packFormat , $ randomBytes ) [ 1 ] ; if ( is_callable ( $ callback ) ) { $ value = call_user_func ( $ callback , $ value ) ; } $ data .= $ value ; } return substr ( $ data , 0 , $ length ) ; }
Generate random data based on the provided parameters

@param int $length Amount of characters of generated data
@param int $packSize Amount of bytes for unpack function
@param string $packFormat Definition of format for unpack function
@param callable $callback a function to manipulated unpacked value
@return boolean|string The generated string
Generate random data based on the provided parameters