Thomas
Thomas

Reputation: 2767

Any recommendation of scripts or tools to rename all variables and method names?

I was wondering if there is any tool or script for renaming all variables and method/function names in a piece of code (id specially be interested in one for java code, but recommendation for other languages are welcome).

I basically do not like to post my code in the web (stack overflow, forums, etc) with the original variable/method names (maybe I am too paranoid =D) and I would like to avoid to change them manually and possibly have some inconsistencies.

So I would be interested in something that does the whole re-factoring in a batch (all variables and all function names) and that I can apply just to a piece of code (I do not want/need to apply to the whole file)

I looked a bit around for it but could not find any (maybe I've been using the wrong keywords)

Upvotes: 2

Views: 1743

Answers (2)

Ira Baxter
Ira Baxter

Reputation: 95334

You want an obfuscation tool. See our Java Obfuscator that operates on source code.

Used properly, you can "rename" the variables to scrambled names (or even names you choose), and still end up with functionally correct code that compiles and runs.

Upvotes: 0

What you are looking for is actually an obfuscation tool, which makes it more difficult for someone to de-compile and analyze your code once it's distributed.

Take a look at ProGuard (StackOverflow), which is used for minimizing and obfuscating compiled Java code.

Edit: Oops, just noticed that you want to obfuscate the actual Java code, not the byte code. My bad. In that case, I would probably look into doing it manually. Posting huge chunks of code to a forum is probably not improving the chances of getting a useful answer anyway. Small pieces demonstrating the issue is the way to go, IMO.

Upvotes: 1

Related Questions