Advertisement
RaZgRiZ

Fake Keygen in LUA

May 13th, 2012
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.59 KB | None | 0 0
  1. math.clamp = function(val, low, high)
  2.     return math.max(low, math.min(val, high))
  3. end
  4.  
  5. substr = function(str, idx, len)
  6.     return str:sub(idx, idx + len - 1)
  7. end
  8.  
  9.  
  10. function keygen(arg1, arg2)
  11.     local chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
  12.     local sect = arg1 > 0 and math.clamp(arg1, 3, 10) or 5
  13.     local len = arg2 > 0 and math.clamp(arg2, 3, 8) or 4
  14.     local tmp = ""
  15.  
  16.     math.randomseed(os.time())
  17.  
  18.     for i=1,sect do
  19.         for p=1,len do
  20.             tmp = tmp..substr(chars, math.random(1, #chars), 1)
  21.         end
  22.         if i < sect then tmp = tmp.."-" end
  23.     end
  24.     return(tmp)
  25. end
  26.  
  27.  
  28.  
  29. print(keygen(5, 5))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement