1
0
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:
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' package.cpath = __api__.apiroot..'/?.so'
require("antd") require("antd")
std = modules.std() std = modules.std()

View File

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