03.06.2024, 06:40
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)