For a long time, JavaScript front-end code must be parsed in plain text by IE. Some encrypted JS such as JScript. Encode has been cracked for a long time due to the treasure of the tree. There are also some encryption methods, through complex transformations, to change the source code, but eventually all escape the final trial, such as unescape, document. write, eval statement to restore. The best way to protect JavaScript code is obfuscation. The goal of obfuscation is to make it easier to read and write code than to write code directly. obfuscation is not non-cracking, but increases the cracking cost, JAVA and C # encryption adopts obfuscation. In this way, obfuscation of very core code cannot protect the code, but does JS have such code? This program does not use the compilation principle, its word segmentation parsing idea is based on mechiland (http://www.jzchen.net) code highlighting program, referred to the Blue classic encryption obfuscation topic discussion.
<HTML> <HEAD> <TITLE> Cunfusion </TITLE> <META content = "MSHTML 6.00.2800.1528" name = GENERATOR> <META content = "" name = Author> <META content = "" name = Keywords> <META content = "" name = Description> </HEAD> <BODY> <TEXTAREA id = code rows = 12 cols = 100>/* This is class */function xx (num, str) {// specifies var a = num; this. aa = a; this. bb = function () {alert (str);} this. cc = function () {for (var I = 0; I <10; I ++) {document. title = I ;}} xx. prototype. dd = function () {alert ("dd");} var a = new xx (100, "hello"), B = new xx (0, "ttyp "); eval (". aa = 20 ");. bb (); B. dd (); alert (. aa );
</Textarea>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
Finally, in principle, I do not approve of code obfuscation encryption. This program is written for the purpose of research. This program is original and will be added to subsequent code compression functions. please correct me if you have any questions in the program, please specify the source for any reprint.