Encrypt/scramble Code?

Ask all of your support questions here

Encrypt/scramble Code?

Postby Unknown To You » Thu May 24, 2012 1:32 am

How might one scramble my .lua files so that the code is not readable by others who come across my game, like the .lua files in Chains and 8-Bit Commando?
Unknown To You
 
Posts: 7
Joined: Sat Nov 12, 2011 6:27 am

Re: Encrypt/scramble Code?

Postby Ivan » Thu May 24, 2012 3:33 am

The code it those games is compiled which makes it not directly readable.
You can compile your code using the included "luac.exe" (doc available here) which also (supposedly) makes it load faster.

When you have a bunch of Lua files in a single directory you can compile them using the following batch command (just make sure you have backups since the command overwrites the files with the compiled versions):
Code: Select all
for /r %%i in (*) do luac.exe -s -o "%%i" "%%i"


PS. I think there might be 3rd party tools for Lua 'code obfuscation' but it's usually not worth the time.
Ivan
Site Admin
 
Posts: 415
Joined: Thu Dec 27, 2007 9:21 pm

Re: Encrypt/scramble Code?

Postby Unknown To You » Thu May 24, 2012 4:18 am

Thank you so much!
Unknown To You
 
Posts: 7
Joined: Sat Nov 12, 2011 6:27 am

Re: Encrypt/scramble Code?

Postby Unknown_To_You » Mon Jun 18, 2012 2:49 am

What if I wanted to decompile something after I compiled it for testing?
Be nice to nerds, chances are you'll end up working for one.
    -Bill Gates
Unknown_To_You
 
Posts: 10
Joined: Thu Feb 16, 2012 3:28 pm

Re: Encrypt/scramble Code?

Postby Ivan » Mon Jun 18, 2012 5:16 pm

I don't know of an easy way to convert compiled Lua bytecode back to Lua.
There may be some tools out there for de-compiling Lua bytecode but I never tried using any of them.
That's the point of compiling it, right - so that your original code can't be easily read?
So, yes, you always want to have backups of the original, non-compiled Lua code.

PS. Please be careful with the above batch command since it overwrites Lua files RECURSIVELY starting from the directory where you run it.
Ivan
Site Admin
 
Posts: 415
Joined: Thu Dec 27, 2007 9:21 pm


Return to Support

Who is online

Users browsing this forum: No registered users and 1 guest

cron