Skip to content

Instantly share code, notes, and snippets.

@Elmuti
Created May 11, 2015 16:24
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 Elmuti/347be47686251f08a877 to your computer and use it in GitHub Desktop.
Save Elmuti/347be47686251f08a877 to your computer and use it in GitHub Desktop.
local chars = "abcdefghijklmnopqrstuvwxyz0123456789"
function flipCoin()
local bools = {true, false}
return bools[math.random(1, #bools)]
end
function randChar()
local n = math.random(1, 36)
local c = chars:sub(n, n)
local heads = flipCoin()
if heads and tonumber(c) == nil then
return c:upper()
else
return c
end
end
function randomPassword(length)
local pw = ""
for c = 1, length do
pw = pw .. randChar()
end
return pw
end
local pw = randomPassword(12)
print(pw)
io.read()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment