By John Koster
The quickRandom
helper method is similar to random
in that it generates a random string to a given $length
. The quickRandom
helper method does not rely on the OpenSSL extension, and generates its random strings from a pool of alpha-numeric characters.
The signature for the quickRandom
helper method is:
quickRandom($length = 16)
While the quickRandom
function is useful for fast generation of random strings (for use in URI's, tokens, etc), , it should not be used in instances where cryptographically secure strings are required.
The following examples show quickRandom
sample output:
1use Illuminate\Support\Str;
2
3// LDM03NP6upx1NUMt
4echo Str::quickRandom();
5
6// jlxyb2YBCxPLZ6OL
7echo Str::quickRandom();
8
9// rlLdOd0YIWZxdmTZMBkItbsduCNUKck2
10echo Str::quickRandom(32);
∎