Obfuscator

Monkey Targets Forums/HTML5/Obfuscator

Midimaster(Posted 2013) [#1]
Has somebody experiences about obfuscated javascript code?

I see, that all "main.js" of my html5 apps are clearly readable. It would be very helpful if at least the variable names, function names and strings would be reduced to a short string or obfuscated.

I tried an online obfuscator, but the result was double size and not working....

***EDIT***

Ok,... I fould Google Closure. It seems to work pretty good. The code was reduced to a third, all names are a or b or c or a combination of it. The strings are kept as they have been.

Now it would be very helpful, if MONKEY eliminates the PRINT command lines in RELEASE version. I use this only for debug purposes. Mark, could you add a feature to switch ON/OFF elimination in TED?


Raz(Posted 2013) [#2]
Google have something called Closure that can be used

https://developers.google.com/closure/compiler/


therevills(Posted 2013) [#3]
Now it would be very helpful, if MONKEY eliminates the PRINT command lines in RELEASE version. I use this only for debug purposes. Mark, could you add a feature to switch ON/OFF elimination in TED?

I do use PRINT for debugging too, but I guess someone could use it for their actual game.

What about wrapping Print yourself?
Strict

Function Main:Int()
	Print "Start"
	Return 0
End

Function Print:Void(str:String)
	#If CONFIG="debug"
		monkey.Print str
	#End
End



Midimaster(Posted 2013) [#4]
This is the way I do it alread to switch on/off debug printing to a console.

But it is no solution if I want to obfuscate all string texts. Comment out all print commands is a possibility, because monkey compiler eliminates such comments.

I do not ask for a elimination of PRINT commands, but I want to have a flag in TED's setting window, where the user can decide how to handle he PRINT commands.


therevills(Posted 2013) [#5]
if I want to obfuscate all string texts

Why would you want to do that? Say if you use DrawText in your game, you wouldn't want the string to obfuscated!

but I want to have a flag in TED's setting window

TED is just a code editor, Monkey is the place you want to control it and you can with the CONFIG pre-processor.


Midimaster(Posted 2013) [#6]
I want to eliminate the PRINT commands, because they say a lot about my code. And if they still are inside an obfuscated script, they still give a hint, what the original variable name was:

LicenceCode=LoadText("...
Print "Licence code= " + LicenceCode


So I can create a pre precessor function and and a corresponding flag which could eliminate all lines wih PRINT at the left? Is it such flexible?


programmer(Posted 2013) [#7]
You can comment all "print(" in the main.js. Example (*nix):
sed 's#\(print("\)#// \1#g' main.js > main_noprint.js

Closure will remove commented lines.