1.2 KiB
1.2 KiB
weight | title | description | icon | date | lastmod |
---|---|---|---|---|---|
100 | MV_ENC_FUNC | Encrypts functions | code_blocks | 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. There are no restrictions on the length or the allowed characters of the keys, only that they are the same.
{{% alert context="info" text="Note: LPH_ENCFUNC
is an available alias." /%}}
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!" /%}}