nl_tokens: Returns a random string with the specified length by randomly selecting characters from the pool provided . If the character pool is not provided the default pool will contain all numbers and letters ( both uppercase and lowercase ) . Usage : $randomString ( 5 ) ; // 2U8cA $randomString ( 5 ABC123 ) ; // AB2AC
pl_tokens: function $randomString ( length , characterPool ) { if ( typeof characterPool !== 'string' ) { characterPool = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" ; } var text = "" ; for ( var i = 0 ; i < length ; i ++ ) { text += characterPool . charAt ( Math . floor ( Math . <mask> ( ) * characterPool . length ) ) ; } return text ; }