使用ProGuard,我如何只混淆一堂课? [英] With ProGuard, how do I obfuscate just one class?

查看:91
本文介绍了使用ProGuard,我如何只混淆一堂课?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是聪明的ProGuard配置,仅混淆一个特定类com.acme.Algorithm的私有方法和常量?

What would be a smart ProGuard configuration to obfuscate just the private methods and constants of one particular class com.acme.Algorithm?

我只是想混淆一下,因为它包含的算法在不小心打开.jar时不应该是显而易见的.

I would like to obfuscate just that, because it contains an algorithm that should not be plain obvious when accidentally opening the .jar.

我是ProGuard新手. AFAIU,您必须使用"keep",但是"do obfuscate"的正面逻辑不可用,对不对?那么如何从保留一切"配置中排除我的班级呢?注意:我暂时不希望混淆其他类,因为我想让客户看到有意义的堆栈跟踪.

I'm a ProGuard newbie. AFAIU, you have to use "keep", but the positive logic of "do obfuscate" is not available, right? So how to exlude my class from a "keep everything" config? Note: I don't want to obfuscate other classes for the moment, because I want to allow the customer to see meaningful stacktraces.

推荐答案

混淆单个类不会有太大效果:它可能会更改类名以及一些字段名和方法名,并且可能会优化某些代码.混淆对于隐藏小的信息往往不太有效.您混淆的应用程序代码越多,就越难理解.

Obfuscating a single class won't have much effect: it may change the class name and a few field names and methods names, and it may optimize some code. Obfuscation tends to be less effective for hiding small pieces of information. The more application code you obfuscate, the more difficult it becomes to understand.

话虽如此,您可以指定:

That being said, you can specify:

-keep class !com.acme.Algorithm { *; }

它将所有类/字段/方法保留在com.acme.Algorithm之外.

It keeps all classes/fields/methods outside of com.acme.Algorithm.

这篇关于使用ProGuard,我如何只混淆一堂课?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆