Skip to content

Instantly share code, notes, and snippets.

@smt116
Created March 17, 2015 18:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smt116/5219af857cfdd2674052 to your computer and use it in GitHub Desktop.
Save smt116/5219af857cfdd2674052 to your computer and use it in GitHub Desktop.
function string.random(length)
if length < 1 then return nil end
local str = ""
for i = 1, length do
n = math.random(32, 122)
if (n > 32 and n < 48) or (n > 57 and n < 65) or (n > 90 and n < 97) then n = math.random(97, 122) end
str = str .. string.char(n)
end
return str
end
print(string.random(100))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment