Reputation: 1261
For an evaluation I want to encrypt all strings in my APK file with DexGuard, but without using the obfuscation, shrinking or optimization options.
Is this possible or am I forced to obfuscate the APK to encrypt it?
I use the following command line to encrypt all classes:
java -jar dexguard.jar @conf.pro -dontwarn -dontobfuscate -dontshrink -dontoptimize -injar in.jar -libraryjars android.jar -outjars out.apk
The conf.pro looks like this:
-dontpreverify
-repackageclasses ''
-allowaccessmodification
-optimizations !code/simplification/arithmetic
-keepattributes *Annotation*
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
#...
-encryptstrings class uk.co.senab.actionbarpulltorefresh.library.BuildConfig
-encryptstrings class uk.co.senab.actionbarpulltorefresh.library.PullToRefreshAttacher$ViewDelegate
-encryptstrings class uk.co.senab.actionbarpulltorefresh.library.PullToRefreshAttacher$Options
#...
I have used the tool jar tf ...
to get all class names and then added all classes with -encryptstrings class ...
after filtering like in the conf.pro file.
My problem is that nothing is encrypted in the out.apk.
What is wrong with my settings?
Thanks in advance for any help.
UPDATE:
I have tried all kind of combinations to encrypt the APK without obfuscation, but it is not possible. So my resume is that encryption is only possible with obfuscation with DexGuard.
The only changes I see to encrypt with DexGuard without obfuscation is to encrypt with obfuscation and use the mapping file to restore the names.
But I haven't tried it.
Upvotes: 3
Views: 1392
Reputation: 6200
That is correct, for string encryption to work, you need to enable obfuscation.
In order to prevent any obfuscation of classes/methods/fields you can add the following configuration:
-keep class * { *; }
Upvotes: 2