random-string to <random string> \
[ length <string length> ] \
[ number | binary ]
random-string obtains a random string of length <string length>. If "length" clause is omitted, the length is 20 by default.
If "number" clause is used, then the resulting string is composed of digits only ("0" through "9").
If "binary" clause is used, then the resulting string is binary, i.e. each byte can have an unsigned value of 0-255.
By default, if neither "number" or "binary" is used, the resulting string is alphanumeric, i.e. digits ("0" through "9") and alphabet letters ("a"-"z" and "A"-"Z") are used only.
Random generator is based on the Linux random() generator seeded by local process properties such as its PID and time. A single process is seeded once, and thus any number of requests served by the same process will use a subset of the process' random sequence. Due to joint entropy, each result given to any request is random, not just within a single request, but among any number of different requests.
Examples
Get a 100-digit long random value (as an alphanumeric string):
random-string to str length100 pf-out"%s\n", str
Get a random number of length 10 in string representation:
random-string to str length10 number pf-out"%s\n", str
Get a random binary value that is 8 bytes in length - this value may contain null bytes (i.e. it will contain bytes with values ranging from 0 to 255):