Java Obfuscator - Lite

by Peter Jaric

When you're programming you may sometimes feel that you need to hide some code from a coworker or a static code analysis tool. If your language happens to be Java, you have come to the right place!

Enter your code in the source code area below and an obfuscated version will appear below. Can't think of some code right now? Try this example.

The result will look like a comment (even when using an IDE), but in reality the code will execute.

Source code

Obfuscated code

Copy and paste the code in the white box into your Java class.


How does that work? What's that Unicode gibberish?

A fun thing about Java is that in addition to ordinary characters, it's perfectly valid to use unicode escapes in the source code. So \u0061\u0020\u003d\u0020\u0031\u003b is equal to a = 1;, for example. Read more in the specification.

This tool creates something resembling a comment filled with unicode escapes by:

  1. starting a comment with plain characters
  2. ending it with */ in unicode escapes
  3. adding the code converted to unicode escapes
  4. starting a new comment with /* in unicode escapes
  5. and finally ending that comment with */ in plain characters

See the deobfuscated code below.

The obfuscated code is very easy to convert back into readable characters, but it might fool someone not familiar with this Java feature. Also, it could be used to bypass static code analysis tools that are not built to handle unicode escapes. I have not researched this part, but would be happy to hear about it, if anyone tries something like that.

Deobfuscated code


Tweet about this
Created by @peterjaric -