Regarding Encrypted 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
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:
- YUI Compressor
- Google Closure Compiler
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.
精彩评论