Nathan F.
Nathan F.

Reputation: 3479

File obfuscation using ProGuard

I'm wondering if someone can tell me how to obfuscate a single file, or maybe just two files, inside a jar file using proguard. I'm hoping that keeping every single class but the one i want to obfuscate isn't my only option, where as that takes a ton of time and is very tedious.. So, Is it possible to only obfuscate a single class? If so, how.. Thanks in advance!

Upvotes: 1

Views: 2168

Answers (2)

Eric Lafortune
Eric Lafortune

Reputation: 45676

Obfuscating a single class is generally not very useful: it will be easy to find and easy to reverse-engineer, since other classes and references to them remain readable. ProGuard therefore obfuscates all classes (except the specified ones) by default.

That being said, this should work:

-keep class !mypackage.MySecretClass, !mypackage.MyOtherSecretClass {
    *;
}

It preserves the class/field/method names of all classes except the specified one. In other words, it only obfuscates the specied classes.

Upvotes: 1

rob
rob

Reputation: 6247

You can exclude all the items except the ones you want to obfuscate; see How to keep/exclude a particular package path when using proguard?

If that doesn't seem practical, a workaround would be to package the files you want to obfuscate in their own jarfile, run ProGuard, then repackage those files with the other files you want to include in a new jarfile.

Upvotes: 0

Related Questions