1014 B
1014 B
weight | title | description | icon | date | lastmod |
---|---|---|---|---|---|
100 | MV_ENC_FUNC | Encrypts functions | article | 2025-05-01T18:47:58-05:00 | 2025-05-01T18:47:58-05:00 |
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.
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
{{% alert context="warning" text="Note: if your plan doesn't include virtualization support, MV_ENC_FUNC
is a no-op where the passed function is mangled normally and not virtualized or encrypted!" /%}}