我想做一个JavaScript应用程序,不是开源的,因此我希望学习如何可以混淆我的JS代码?这可能吗?


当前回答

有许多免费的JavaScript混淆工具;然而,我认为重要的是要注意,很难混淆JavaScript到不能进行逆向工程的地步。

为此,我在一定程度上使用了几个选项:

YUI Compressor. Yahoo!'s JavaScript compressor does a good job of condensing the code that will improve its load time. There is a small level of obfuscation that works relatively well. Essentially, Compressor will change function names, remove white space, and modify local variables. This is what I use most often. This is an open-source Java-based tool. JSMin is a tool written by Douglas Crockford that seeks to minify your JavaScript source. In Crockford's own words, "JSMin does not obfuscate, but it does uglify." It's primary goal is to minify the size of your source for faster loading in browsers. Free JavaScript Obfuscator. This is a web-based tool that attempts to obfuscate your code by actually encoding it. I think that the trade-offs of its form of encoding (or obfuscation) could come at the cost of filesize; however, that's a matter of personal preference.

其他回答

作为JavaScript/HTML/CSS混淆器/压缩器,你也可以尝试Patu Digua。

我可以推荐Patrick J. O'Neil的JavaScript Utility。它可以模糊/紧凑和压缩,它似乎很擅长这些。也就是说,我从未尝试将它集成到任何类型的构建脚本中。

至于混淆和缩小,我不太喜欢前者。它使调试不可能(错误在第一行…“等等,只有一行”),而且他们总是要花时间打开行李。但如果你需要…好。

试试这个工具Javascript混淆器

我在自己的HTML5游戏中使用了它,不仅将其大小从950KB减少到150 kb,而且还使源代码不可读闭包编译器和迷你器是可逆转的,我个人不知道如何扭转这种混乱。

我已经使用Jasob多年了,它无疑是最好的混淆器。 它有一个高级的用户界面,但仍然直观和易于使用。 它还可以处理HTML和CSS文件。

使用它的最好方法是给所有私有变量加上下划线之类的前缀,然后使用排序功能将它们组合在一起,并将它们作为混淆的目标进行检查。

用户仍然可以查看您的源代码,但是当您的私有变量从_sUserPreferredNickName转换为。

该引擎将自动统计目标变量的数量,并优先考虑它们以获得最大的压缩。

我不是为雅各布工作,我从推销他们中得不到任何东西,只是提供一些友好的建议。 缺点是它不是免费的,而且有点贵,但与其他选择相比还是值得的——“免费”选项甚至无法相提并论。

你绝对应该考虑一下Obfuscriptor。

我超越了我们从其他工具(如YUI Compressor或谷歌Closure)中看到的典型Javascript缩小技巧。

经过模糊处理的代码看起来更像是加密的。不像我以前见过的任何东西。