Version: v0.8.1 - Beta.  We welcome contributors & feedback.

String.randomToken

String.randomToken($numChars) -> string

Description

Create a string of random base-36 characters, consisting of lowercase letters [a-z] and digits [0-9].

The $numChars argument determines the number of characters in the string.

This function is cryptographically secure.

String.randomToken(40)
//= '5tp9u3swocd5tx7bs06v1fzdv8fwjkzyo4jdl3q7'

See Also