c_AddUser with generate password feature

You can share your Lua Scripts with everybody here.
Post Reply
fox-it
Posts: 1
Joined: Wed Jan 16, 2013 7:39 pm

c_AddUser with generate password feature

Post by fox-it »

Hi Forum,
is there a way to create users with LUA and use the generate random password feature?
Would be nice to be able to create users on the command line and get a randomly generated password as output.
regards,
Benjamin
FTP
Site Admin
Posts: 1918
Joined: Tue Sep 29, 2009 6:09 am

Re: c_AddUser with generate password feature

Post by FTP »

You can generate a random password like this:

Code: Select all

local password = ""
local charArray = {'0','1','2','3','4','5','6','7','8','9','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'}
math.randomseed(os.time())
math.random()
for i=1,8 do
	local nowindex = math.random(1,table.maxn(charArray))
	password = password..charArray[nowindex]
end

print(password)
Post Reply