Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- math.clamp = function(val, low, high)
- return math.max(low, math.min(val, high))
- end
- substr = function(str, idx, len)
- return str:sub(idx, idx + len - 1)
- end
- function keygen(arg1, arg2)
- local chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
- local sect = arg1 > 0 and math.clamp(arg1, 3, 10) or 5
- local len = arg2 > 0 and math.clamp(arg2, 3, 8) or 4
- local tmp = ""
- math.randomseed(os.time())
- for i=1,sect do
- for p=1,len do
- tmp = tmp..substr(chars, math.random(1, #chars), 1)
- end
- if i < sect then tmp = tmp.."-" end
- end
- return(tmp)
- end
- print(keygen(5, 5))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement