mirror of
https://github.com/lxsang/antd-lua-plugin
synced 2024-12-27 09:58:21 +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'
|
package.cpath = __api__.apiroot..'/?.so'
|
||||||
require("antd")
|
require("antd")
|
||||||
std = modules.std()
|
std = modules.std()
|
||||||
|
@ -146,3 +146,16 @@ end
|
|||||||
function firstToUpper(str)
|
function firstToUpper(str)
|
||||||
return (str:gsub("^%l", string.upper))
|
return (str:gsub("^%l", string.upper))
|
||||||
end
|
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