Skip to content

Instantly share code, notes, and snippets.

@ChaunceyHoover
Created August 8, 2019 12:56
Show Gist options
  • Save ChaunceyHoover/6e0ba8a18115517ffce39fca86a1e8db to your computer and use it in GitHub Desktop.
Save ChaunceyHoover/6e0ba8a18115517ffce39fca86a1e8db to your computer and use it in GitHub Desktop.
Simple lua string generator
function rand_str(len)
len = tonumber(len) or 1
local function rand_char()
return math.random() > 0.5
and string.char(math.random(65, 90))
or string.char(math.random(97, 122))
end
local function rand_num()
return string.char(math.random(48, 57))
end
local str = ""
for i = 1, len do
str = str .. (math.random() > 0.5 and rand_char() or rand_num())
end
return str
end
--print(rand_str(10)) => 10 random alphanumeric characters
@ChaunceyHoover
Copy link
Author

Just importing old pastebin scripts to my gist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment