mirror of
https://github.com/lxsang/antd-lua-plugin
synced 2024-12-26 01:18:22 +01:00
add random salt string generation in core API
This commit is contained in:
parent
e6004d8ccd
commit
7a1c58009b
@ -1,4 +1,4 @@
|
||||
|
||||
math.randomseed(os.clock())
|
||||
package.cpath = __api__.apiroot..'/?.so'
|
||||
require("antd")
|
||||
std = modules.std()
|
||||
|
@ -145,4 +145,17 @@ end
|
||||
|
||||
function firstToUpper(str)
|
||||
return (str:gsub("^%l", string.upper))
|
||||
end
|
||||
|
||||
|
||||
local charset = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890"
|
||||
|
||||
function utils.generate_salt(length)
|
||||
local ret = {}
|
||||
local r
|
||||
for i = 1, length do
|
||||
r = math.random(1, #charset)
|
||||
table.insert(ret, charset:sub(r, r))
|
||||
end
|
||||
return table.concat(ret)
|
||||
end
|
Loading…
Reference in New Issue
Block a user