Obsfucate Lua Code

Hi Facepunch i want to obfuscate my lua code so it will be harder for leakers/crackers to crack it, yes IK its still very easy to deobsfucate, but still i wanna know how to do it, i’ve seen some guy obsfucate a lua string with" _G[string.format(string.rep" or something

My best advice is: don’t bother. Your clientside code shouldn’t have anything very secret anyway - the fancy stuff should be done on the server. If you’re trying to prevent people from stealing your HUD or something like that, well… I don’t know much about obfuscation, but one thing you can do is minify it - that means removing all comments, changing all local variables to meaningless single- or double-letter names, and removing all whitespace. minification reduces filesize and therefore clients can connect a little bit faster. As a side effect, the code becomes nearly unreadable.

There’s software that does this, don’t do it yourself of course.

Either way, all clientside code CAN be stolen, as you seem to already know. The best you can do is make it impractical to understand.

what software?

Obfuscation is just making the script harder to read. You can just change every variable and function name to something weird like ‘nEfZhIPXtd’ and it would be obfuscated. You don’t need any software to do it.

It doesn’t exist, just stop asking

lol velkon ur funny as usual

Having your code DRM protected, obfuscated etc. doesn’t increase your sales.

I removed DRM 2 months ago, I see no loss in sales - despite hundreds of leaks of my addons coming out that time.

I think your best bet to obfuscate lua would be… https://github.com/mlnlover11/XFuscator
Then again there is no point in obfuscating as it reduces both performance and readability.

Besides if someone wanted to leak your code they would find a way to deobfuscate it.

pretty much this, as long as you keep updates coming for the official version most people will buy it rather than wait for somebody to releak the newest version

Very much this, not to mention that people who weren’t planning on buying your stuff won’t do it just because there’s no leak of it, they’ll either wait or not get it at all :stuck_out_tongue:

if you actually want to “obfuscate” your code just use a lua minifier

Ignore the comments telling you to don’t bother. Saying not to bother because it can be bypassed is akin to saying to not bother putting a fence around your lawn because someone can just jump over it.

OP wants his scripts to be harder to crack. Some form of DRM, used in conjunction with obfuscation, will do just that.

That would be assuming he intends on selling his scripts. I’m guessing you expect him to do that on SF? I doubt SF mods would approve a script they can’t even read.

There currently is no glua minifier, believe me, I’ve looked.

You could use one of many lua minifiers, but they don’t support glua-specifc operators.

I’m actually in the middle of working on one (on and off). If you just need it some time in the future, wait a bit. If you need it now, feel free to use it, but it’s still got some (tons of) bugs. Use at your own risk.

He said leakers for a reason.

You can leak code without that code being sold. If I run a server and have all of my private code on it and someone somehow gains access to that code and posts it on the internet, that is a leak.

If someone managed to break in, then he wouldn’t have a problem deobfuscating the code.

You could make a system which downloads the code from a server, to download the files the gmod server would need a auth key, you’d just have to impliment a API on a webserver to accept the key and let the server download

And this obfuscates code… how?

ok i found out how to obsfucate variables with string.format and stuff, but how can i obsfucate it with string.gsub, i think only veteran lua coders will understand what im even talking about