Created
May 11, 2015 16:25
-
-
Save Elmuti/a49975e1c748fc56dc24 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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