I have been asked a couple of times if it is possible to obscure scripts, so plugin authors can hide their workings (with a view to getting a fee, I think).
With Lua this is reasonably possible, although bear in mind any copy protection scheme can be cracked if you try hard enough.
Basically you write your script/plugin or whatever "in the clear" first to test it. Then when you are ready, save the script part to a separate file, (eg. myscript.lua) and then use the Lua standalone compiler to "compile" it. This produces byte-code (intermediate interpreter code, not machine code) that can be read by Lua.
eg.
Test file: test.lua
Compile it:
Run it:
Inside your script file load the compiled file:
The 'dofile' command will load both source or object, auto-detecting the difference.
You can list the "object", and get some information from it, however if suitably obscured then it should hide what you are doing:
With Lua this is reasonably possible, although bear in mind any copy protection scheme can be cracked if you try hard enough.
Basically you write your script/plugin or whatever "in the clear" first to test it. Then when you are ready, save the script part to a separate file, (eg. myscript.lua) and then use the Lua standalone compiler to "compile" it. This produces byte-code (intermediate interpreter code, not machine code) that can be read by Lua.
eg.
Test file: test.lua
print ("Hello, world")
table.foreach (string, print)
print "done"
Compile it:
luac -o test.luac test.lua
Run it:
lua test.luac
Inside your script file load the compiled file:
dofile 'test.luac'
The 'dofile' command will load both source or object, auto-detecting the difference.
You can list the "object", and get some information from it, however if suitably obscured then it should hide what you are doing:
luac -l test.luac
main <test.lua:0> (12 instructions, 48 bytes at 00411590)
0 params, 3 stacks, 0 upvalues, 0 locals, 6 constants, 0 functions
1 [1] GETGLOBAL 0 0 ; print
2 [1] LOADK 1 1 ; "Hello, world"
3 [1] CALL 0 2 1
4 [3] GETGLOBAL 0 2 ; table
5 [3] GETTABLE 0 0 253 ; "foreach"
6 [3] GETGLOBAL 1 4 ; string
7 [3] GETGLOBAL 2 0 ; print
8 [3] CALL 0 3 1
9 [5] GETGLOBAL 0 0 ; print
10 [5] LOADK 1 5 ; "done"
11 [5] CALL 0 2 1
12 [5] RETURN 0 1 0