Search code examples
javaencryptionproguardobfuscation

proguard Obfuscate field values of enum class


I want to obfuscate the field name and field value of enum class(Coffee).

public enum Coffee {
    
    DUTCH("dutch coffee"),
    COLD_BREW("cold brew");

    private String value;

    Coffee(String value) {
        this.value = value;
    }
}

So I tried many ways using Proguard, but the result I got is this.

public enum a {
    
    a("dutch coffee"),
    b("cold brew");

    private String value;

    a(String value) {
        this.value = value;
    }
}

But this is what I want.

public enum a {
    
    a("c"), or a(c)
    b("d"); or b(d)

    private String value;

    a(String value) {
        this.value = value;
    }
}

I don't know which option to apply.

[Question]

  1. Is it possible to obfuscate or encrypt the field value of the enum class? According to the data I have searched, proguard does not provide obfuscation or encryption..
    (Hiding strings in Obfuscated code)

  2. If field value can be obfuscated or encrypted using progad, I would like to get a hint.


Solution

  • You are looking for a solution that can apply string encryption, this is not something you can do with ProGuard or R8.

    ProGuard (and R8) can only apply basic name obfuscation to your code.