This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

math.random() allways retuns 0.7942
#5
Use this. Modify the character list as needed.
Code:
function randompassword(length)
  local characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
  local max = #characters - 1
  local buffer = {}

  length = length or 12

  local ts, tu = os.microtime()
  math.randomseed(ts * 1e6 + tu)

  for i = 1, length do
    local rnd = math.random(1, max)
    buffer[ i ] = characters:sub(rnd, rnd)
  end

  return table.concat(buffer)
end

length = 8
password = randompassword(length)
log(password)
Reply


Messages In This Thread
math.random() allways retuns 0.7942 - by kike - 03.02.2023, 11:31
RE: math.random() allways retuns 0.7942 - by admin - 03.06.2024, 06:40

Forum Jump: