简体   繁体   English

使用ProGuard进行文件混淆

[英]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. 我想知道是否有人可以告诉我如何使用proguard对jar文件中的单个文件或两个文件进行混淆。 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! 如果是这样,如何..在此先感谢!

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. 因此,ProGuard会默认模糊所有类(指定类除外)。

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. 换句话说,它只会混淆指定的类。

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? 请参阅使用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. 如果这似乎不可行,一种解决方法是将要混淆的文件打包到其自己的jarfile中,运行ProGuard,然后将这些文件与要包含在新jarfile中的其他文件重新打包。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM