如何保护/加密 Java 类? [英] How can you protect/encrypt your Java classes?

查看:21
本文介绍了如何保护/加密 Java 类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

前段时间,在我的工作中,我需要保护一些类不被其他人阅读代码.为此,我创建了一个 EncryptedClassLoader,它加载以前加密的类,也可以加载普通(未加密)的类.以这种方式工作有点复杂,测试也是如此(编译,然后加密,然后解密).

Some time ago, in my work I needed to protect some classes against other people to read the code. For that purpose, I created a EncryptedClassLoader, that loaded previously encrypted classes, and can load normal (not encrypted) classes as well. Working in that way was a little complicated, and testing too (compile, then encrypt, and then decrypt).

有没有免费的框架可以做我需要的,并且易于处理?我的意思是,不仅混淆,而且加密文件,所以没有人可以读取或调试那部分代码.如果我可以轻松更改加密密钥也很棒(在我的应用程序中,它是硬编码的).

Is there any free framework to do what I needed, and is easy to handle? I mean, not only obfuscate, but also encrypt the files, so none can read or debug that part of code. It would also be great that I can change the keys for encryption easily (in my application, it was hardcoded).

提前致谢.

推荐答案

简而言之,你不能.加密不起作用.这是一篇关于为什么它是 的古老文章使用加密的类加载器毫无意义:

Short answer, you can't. Encryption doesn't work. Here's an oldish article about why it's pointless to use an encrypted class loader:

不幸的是,你错了,都认为你是首先提出这个想法并在认为它确实有效.和原因与加密方案的强度.

Unfortunately, you would be wrong, both in thinking that you were the first to come up with this idea and in thinking that it actually works. And the reason has nothing to do with the strength of your encryption scheme.

您可以对其进行混淆,但这只会到此为止,最后我坚信您的时间最好花在修复错误或添加功能上.

You can obfuscate it, but that will only go so far, and in the end I'm a firm believer that your time would be better spend fixing bugs or adding features.

这篇关于如何保护/加密 Java 类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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