1
0
mirror of https://github.com/lxsang/antd-lua-plugin synced 2024-12-26 17:38:21 +01:00

add random salt string generation in core API

This commit is contained in:
DanyLE 2022-09-02 20:10:35 +02:00
parent e6004d8ccd
commit 7a1c58009b
2 changed files with 14 additions and 1 deletions

View File

@ -1,4 +1,4 @@
math.randomseed(os.clock())
package.cpath = __api__.apiroot..'/?.so'
require("antd")
std = modules.std()

View File

@ -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