Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- — Simple Password Generator —
- local pass = ""
- local nums = {1,2,3,4,5,6,7,8,9,0}
- local letters = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
- local special = {"/", ".", "_", ":", ";", "*", "-", "!", ",", "!", "'", "\""}
- function genPass(length)
- local n = 0
- while n < tonumber(length) do
- local t
- local op = math.random(1, 3)
- --print(op)
- if op == 1 then
- local ul = math.random(1,2)
- local i = letters[math.random(1,26)]
- if ul == 1 then
- t = string.lower(i)
- else
- t = string.upper(i)
- end
- pass = pass..t
- elseif op == 2 then
- pass = pass..nums[math.random(1,10)]
- else
- pass = pass..special[math.random(1,12)]
- end
- n = n + 1
- end
- return tostring(pass)
- end
- print("Password Generator")
- print("Choose a length for your password: ")
- local i = io.read()
- if tonumber(i) == 0 then
- print("Not a number! Generating a password 20 characters long.")
- print("Password generated: ")
- print(genPass(20))
- else
- print("Password generated: ")
- print(genPass(i))
- end
- sys.alert("vib")
Add Comment
Please, Sign In to add comment