Generate a random string (string.random)
Declaration
rs = string.random(pool [, count, bytes_per_char ])
Parameters
- pool
string. Character dictionary to pick from. - count
integer, optional. Number of characters to generate. Default 6. - bytes_per_char
integer, optional. Number of bytes per character. Default 1.
Returns
- rs
string. Generated random string.
Description
Generate a random string. Note: each Chinese character in UTF-8 is 3 bytes.
Example
rs = string.random("qwertyuiopasdfghjklzxcvbnm", 20, 1)
rs = string.random("一二三四五六七八九十", 20, 3)