src/Traits/StringTrait.php
/**
	 * Generate a more truly "random" alpha-numeric string.
	 *
	 * @param int $length
	 * @throws \Exception
	 * @return string
	 * @author https://github.com/illuminate/support/blob/master/Str.php
	 */
Generate a more truly "random" alpha-numeric string.
Generate a more truly " random " alpha - numeric string .
public static function random(int $length = 16): string
	{
		$string = '';
		while (($len = strlen($string)) < $length) {
			$size = $length - $len;
			$bytes = random_bytes($size);
			$string .= substr(str_replace(['/', '+', '='], '', base64_encode($bytes)), 0, $size);
		}
		return $string;
	}
public static function random ( int $ length = 16 ) : string { $ string = '' ; while ( ( $ len = strlen ( $ string ) ) < $ length ) { $ size = $ length - $ len ; $ bytes = random_bytes ( $ size ) ; $ string .= substr ( str_replace ( [ '/' , '+' , '=' ] , '' , base64_encode ( $ bytes ) ) , 0 , $ size ) ; } return $ string ; }
Generate a more truly "random" alpha-numeric string.
Generate a more truly " random " alpha - numeric string .