Generates a random string.
The result is generated using the cryptographically secure random number generator.
string(length, alphabet?)
length
The length of string to generate. Must be greater than zero.
alphabet optional
A string containing characters that can appear in the result. Separate characters are determined using the graphemes function.
If not specified, the result will contain Latin alphanumeric characters:
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
A random string.
random.string(10)
"n6McPqrPH4"
random.string(3, "🏎️🏍️🚲🚃✈️🚀🚢")
"🚲🚀🚲"