如何将C#转换为DLL以隐藏源代码?
如何将我的 C# 代码转换为 DLL 文件,并且 DLL 的用户无法查看我的源代码?
当我按照我一贯的方式制作DLL时,通过制作类库项目,导入我的类并编译它,仍然可以查看源代码。
How can I convert my C# code to DLL file in a way that the user of DLL can’t view my source code?
When I make DLL in the way I always do by making a class library project, importing my classes and compiling it, the source code can still be viewed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
考虑使用混淆器。
Consider using an obfuscator.
如果您正在开发桌面应用程序,将代码转换为 Dll 不会隐藏它(有很多工具可以反编译 dll 或 exe 文件)。
但是如果您使用Asp.Net,那么您可以将您的站点编译为Dll,并且代码在aspx页面中将不可见,它将被编译为Dll,您可以通过在解决方案资源管理器上右键单击您的项目来做到这一点,然后选择发布网站。
但在所有情况下,.Net Exe 文件和 DLL 都很容易被反编译并再次提取源代码,除非您使用工具来混淆代码。
If you are developing desktop applications converting your code to Dll will not hide the it( there are many tools to decompile the dll or exe files).
but if you are using Asp.Net, then you can compile your site to Dll, and the code will not be visible in the aspx pages, it will be compiled to Dll, you can do that by right click on your project on solution explorer, then choose Publish website
But in all cases .Net Exe files and DLL will be easy to decompile and extract the source code again, unless you use tool to obfuscator your code.
如果您的意思是,最终用户可以通过反编译来查看您的源代码,那么您可以使用混淆器来保护自己。
Visual Studio 中内置了标准混淆器。 在菜单中选择“工具/Dotfuscator 社区版”。
If you mean, the end-user can view your source code by decompiling it, you can protect yourself using an obfuscator.
There is standard obfuscator build in into Visual Studio. In the menu choose Tools / Dotfuscator community edition.
我认为我对有关JavaScript混淆的类似问题的答复也适用于这里:简而言之, 何必呢? 你的问题已经在这里得到解答(“使用混淆器”),但我认为找出你的动机是什么也没什么坏处。 一般来说,你提供给人们的代码“在敌人手中”——如果有人想使用它/弄清楚它是如何工作的,他们就会这么做。
I think my reply to a similar question about JavaScript obfuscation applies here as well: in short, why bother? Your question has already been answered here ("use an obfuscator"), but I thought it wouldn't hurt to find out what your motivations are. Generally, code that you give to people is "in the hands of the enemy" -- if somebody wants to use it/figure out how it works badly enough, they will.
我相信您正在寻找一个混淆器。 该工具将获取已编译的 DLL 并重写代码,以防止其他用户对其进行有意义的反编译。 Visual Studio 附带一个免费的 Dotfuscator
注意,这实际上并不会阻止人们查看您的代码。 相反,他们会看到你的代码的一个非常奇怪的翻译。 没有办法阻止人们查看 C# 或任何其他 .Net 语言代码的反编译版本。
这并不是 C# 所独有的。 事实上,这是现有每种语言的缺陷。 反编译C代码是完全可能的。 但不同之处在于,在反编译托管语言(例如 .Net 和 Java)时,维护许多原始代码结构要容易得多,因为元数据保留了原始结构。
I believe you are looking for an obfuscator. This is a tool that will take a compiled DLL and rewrite the code with the intent of it not being meaningfully decompiled by another user. Visual Studio comes with a free Dotfuscator
Note, this will not actually prevent people from looking at your code. They will instead be looking at a very weird translation of your code. There is no way to prevent people from looking at decompiled versions of your code in C# or any other .Net language for that matter.
This is not something that is unique to C#. It is fact a flaw of every language in existence. It's perfectly possible to decompile C code. The difference though is it's much easier to maintain a lot of the original code structure when decompiling managed languages (.Net and Java for instance) because the metadata maintains the original structure.
混淆是您想要搜索的内容。
Visual Studio 中有一个免费的(有限制的)叫做 Dotfuscator。
使用奇特的方法来重命名您的代码并更改流程以掩盖它。
obfuscation is what you want to search for.
There is a free one (that is limited) in visual studio called Dotfuscator.
Uses fancy methods to rename your code and alter flowpaths to obscure it.