Initial JavaScript code obfuscation

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.