declare function MV_ENC_FUNC<A..., R...>(vmFunction: (A...) -> R..., encryptKey: string, decryptKey: string): (A...) -> R...

will virtualize and encrypt the passed function constant with the provided encryptKey. Then decryptKey is evaluated at runtime to grab the key. There are no restrictions on the length or the allowed characters of the keys, only that they are the same.

Valid Usage

local total = 0

local getKey = MV_VM(function()
  -- WARNING: this is just an example! don't do this
  return "pass" .. "word123"
end)

for i = 1, 10 do
  -- referenced upvalues will be captured
  MV_ENC_FUNC(function()
    print("in virtualized function # 1", i)
    total = total + i
  end, "password123", getKey())()
end

return total