I know I can generate a string of random numbers, but is it possible to gernerate a random string of letters and symbols and numbers? And if so, how would I do that?
Create your own.
local upperCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" local lowerCase = "abcdefghijklmnopqrstuvwxyz" local numbers = "0123456789" local symbols = "!@#$%&()*+-,./\:;<=>?^[]{}" local characterSet = upperCase .. lowerCase .. numbers .. symbols local keyLength = 32 local output = "" for i = 1, keyLength do local rand = math.random(#characterSet) output = output .. string.sub(characterSet, rand, rand) end print(output) --Output: nz28IJ..=uPBF}6xeVhOQ7J,LR)CGF46 --Output: 4h<UH%!l.21,;LbG$S2:Ss!Vl>ks{IRJ
Keeping each set separate (lower case, upper case, numbers, etc) makes it easy to dynamically select what sets you want to use. The loop simply runs and selects a random character position and appends it to the final string.
Do note that the quotes, single and double, are left out. You can use the delimiter to add those back in, just be sure to compensate for the length and check for the character(s).