If you found the contents in this blog useful, then please make a donation to keep this blog running. You can make donations via Skrill with email address

Sunday, November 27, 2011

Java Source Code Hiding

I was thinking of a way to hide complex algorithms in source code and it turns out that Java Compiler can compile source code with unicode code character encoding. So for instance a typical HelloWorld class like this
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
Can be written as


And it would compile just fine using javac and will run and print Hello, World!. I wrote a small application which converts any java source file to Unicode encoding so that you can hide your source within your computer from people who have access.

 * @author Shazin Sadakath
public class JavaUnicodeEncoding {
    public static void main(String[] args) throws Exception {
        BufferedReader br = null;
        BufferedWriter bw = null;
        try {
            br = new BufferedReader(new FileReader(args[0]));
            bw = new BufferedWriter(new FileWriter(args[1]));
            String line = null;
            while((line = br.readLine()) != null) {
                for(char c:line.toCharArray()) {
                    bw.write(String.format("\\u%04X",(int) c));
        } catch(ArrayIndexOutOfBoundsException e) {
        } catch(Exception e) {
        } finally {
            if(br != null) {
            if(bw != null) {
    private static void usage() {
        System.out.println("java JavaUnicodeEncoding <input class filename /> <output class filename/>");
You can even use the two interchangeably also
public class HelloWorld {
    public static void main(String[] args) {


Movies Gallery 2011 said...

I have no words for this great post such a awe-some information i got gathered. Thanks to Author.
Vee Eee Technologies| Vee Eee Technologies|

Admin said...

hello could you please tell me step by step how to hide source code in blogger

Milad said...


When decompile dex to jar original source code will visible.

You can not hide source code byr this method!