Loading devShakib…
Generate random strings of any length from the character sets you choose.
How much randomness you have is set by the character set and the length together, and it is worth computing rather than assuming — a 16-character string from a 10-digit alphabet carries far less than a 16-character string from a 62-character one, though they look equally arbitrary.
Which alphabet to choose depends on what handles the string afterwards. Excluding visually confusable characters helps anything a human might read aloud or retype; restricting to unreserved characters matters if it lands in a URL. And a random string is only a secret if it came from a cryptographic source — for a password or a token, that is the property that counts.