explorers' club

explorations in dev, science, sci-fi, games, and other fun stuff!

as3 code obfuscator

Leave a comment

Wanted to share this real quick with folks.

problem

I have been working hard on the as3isolib.v2 trying to prep a test release.  As I haven’t decided on a licensing scheme nor do I want to freely release the source, I needed a way to obfuscate the source code of some of the underlying engine code.  Everything I have seen so far on the web didn’t allow for you to manipulate an individual .as file and preserve the non-private APIs.  It seems rather that most obfuscation programs target out-going SWFs from being decompiled.

desired results

  • be able to preserve original, human-readable source file while producing an obfuscated file
  • be able to preserve the non-private variable, functions and consts
  • be able to integrate into an ANT build script

solution

After doing some digging, I found this nifty little python script by Erik Johnson (http://www.applesaucejuice.net/) that does the first and third things I needed.  After looking at it and figuring out some real basic python, I modified the script to only obfuscate private and function-scoped members:

  • mod’d version (pastebin)(download) – you may encounter some indentation errors when running the script as I do not have a dedicated python IDE
  • original version (github)

Leave a comment