关于加密 Javascript
当我们在网页中编写 javascript 时,其他用户可以看到该 javascript 并了解该脚本是如何工作的。我见过很少有网站以这样的方式编写 JavaScript,用户可以阅读脚本,但无法理解它是如何工作的。因此,出于安全原因,我如何在浏览器可以理解的页面中加密我的 JavaScript?正确渲染,但任何用户可能无法理解流程。正在寻找您的建议。
谢谢
when we write javascript in web page then other user can see that javascript and understand how the script work. i have seen few site where javascript was written in such a way user can read the script but will not be able to understand how it works. so for the security reason how can i encrypt my javascript in the page where browser can understand & render properly but any user may not be able to understand the flow. looking for your suggestion.
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这个过程称为混淆,而不是加密,两者是不一样的。这意味着它使阅读代码变得困难,但并非不可能。
有很多工具可以帮助您实现此目的,例如:
This process is called obfuscation, not encryption which is not the same. It means that it makes it hard to read the code but not impossible.
There are many tools allowing you to achieve this such as:
如果您使用 JavaScript 库,但仍想混淆整个代码库以保护您的 IP,您可以考虑使用与 Closure Compiler 的高级模式兼容的 Dojo Toolkit。当然,您也可以使用 Closure 库,但一般来说,Dojo 比 Closure 库(即在 Google 之外)流行得多。
http://dojo-toolkit.33424 .n3.nabble.com/file/n2636749/Using_the_Dojo_Toolkit_with_the_Closure_Compiler.pdf?by-user=t
完全混淆的代码与纯文本代码具有完全相同的行为,只是它更小,运行速度更快,并且即使经过美化器之后,几乎不可能进行逆向工程。
仅“缩小”的代码(例如 YUI 压缩器、Uglify)在经过美化器后可以轻松进行逆向工程。
If you use a JavaScript library but still want to obfuscate the entire code base to protect your IP, you can consider the Dojo Toolkit which is compatible with Closure Compiler's Advanced mode. Of course, you can also use the Closure Library, but in general Dojo is much more popular than the Closure Library (outside of Google, that is).
http://dojo-toolkit.33424.n3.nabble.com/file/n2636749/Using_the_Dojo_Toolkit_with_the_Closure_Compiler.pdf?by-user=t
Completely obfuscated code has exactly the same behavior as plain-text code, except that it is much smaller, runs much faster, and almost impossible to reverse-engineer, even after passing through a beautifier.
Code that is only "minified" (e.g. YUI compressor, Uglify) can be easily reverse-engineered after passing through a beautifier.