Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

lua - Load code from string without using loadstring() function

There is any way to load code from string without using a loadstring() function?

For example:

local code = {
    {
        Code = [[
            function DoSomething()
                print('making something')
            end
        ]]
    },
    {
        Code = [[
            function DoSomethingElse()
                print('making something else')
            end
        ]]
    },
}

for i = 1, #code do
    local currentCode = code[i].Code
    -- Load this code here, without loadstring()
end

App where I'm writing uses a Lua version that doesn't have the loadstring() function. There is a load() function, which works the same way, but it is not a safe way to load code. It can be easily intercepted. I would like to keep my code as secure as possible.

question from:https://stackoverflow.com/questions/65890901/load-code-from-string-without-using-loadstring-function

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...