Source code encryption several simple methods

Keywords: source code encryption, source code encryption, source code encryption, source code encryption, source code encryption, source code encryption, source code encryption, source code encryption, source code encryption, source code encryption, source code encryption, source code encryption , source code encryption, source code encryption, source code encryption, source code encryption, source code encryption, source code encryption, source code encryption.   

There are various ways of code encryption. Here we collect a few simple source code encryption solutions for your reference in the software development process and strengthen your understanding of encryption technology in the programming process.



Simple JAVA source code encryption:

1. The Java program is named EncryptFile.java. Run the method on the command line as

java EncryptFile input_file passwordoutput_file

2. Implement a simple encryption algorithm for input files using passwords. Two

methods :

2.1 The Encrypt method performs a cyclic bitwise

XOR , the nth character of the input file and the (n% length of the password) ) characters

are bitwise XORed, and the resulting characters are output to the output file one by one, where length is the length of the password.

2.2 The main method first checks whether the command line parameters are correct, including the number of command line parameters, whether the input

file already exists, and whether the output file already exists. If there is an error, an error

message and the program ends. If correct, call the Encrypt method to generate output.txt.

Finally, read the output.txt file and display its contents on the screen.

3. To test the program, execute

java EncryptFile input.txt 12345678output.txt



Simple HTML source code encryption: You

must be familiar with the JAVASCRIPT functions escape() and unescape() (many web pages use them for encryption), which are encoding and decoding strings, such as example code After encrypting with the escape() function, it becomes the following format:

alert%28%22%u9ED1%u5BA2%u9632%u7EBF%22%29%3B

? Do you still understand? Of course, the ASCII character "alert" is not encrypted. If we want, we can write some JAVASCRIPT code to re-encrypt it as follows:

%61%6C%65%72%74%28%22%u9ED1%u5BA2%u9632%u7EBF% 22%29%3B

hehe! how? This time it's completely encrypted!

Of course, the encrypted code cannot be run directly. Fortunately, eval(codeString) is also available. The function of this function is to check the JavaScript code and execute it. The required codeString parameter is a string value containing valid JavaScript code, plus the above Decoding unescape(), the encrypted result is as follows: <SCRIPT LANGUAGE="JavaScript"> varcode=unescape("%61%6C%65%72%74%28%22%u9ED1%u5BA2%u9632%u7EBF%22% 29%3B");eval(code)

</SCRIPT>



Keywords: source code encryption, source code encryption, source code encryption, source code encryption, source code encryption, source code encryption, source code encryption, source code encryption, source code encryption, source code encryption, source code encryption, source code encryption , source code encryption, source code encryption, source code encryption, source code encryption, source code encryption, source code encryption, source code encryption.



The

magic of the escape character "" You may not be familiar with the escape character "", but JavaScript provides some special characters such as: n (newline), r (carriage return), ' (single quotation mark), etc. Do you understand? In fact, "" can also be followed by octal or hexadecimal numbers. For example, the character "a" can be expressed as: "141" or "x61" (note that it is a lowercase character "x"). As for double-byte characters such as Chinese characters "Black" can only be represented as "u9ED1" in hexadecimal (note that it is a lowercase character "u"), where the character "u" represents a double-byte character. According to this principle, the example code can be expressed as:

Octal conversion The hexadecimal escape string is as follows: <SCRIPT LANGUAGE= "JavaScript">eval("1411541451621645042u9ED1u5BA2u9632u7EBF425173") <



/SCRIPT>

The hexadecimal escape string is as follows: <SCRIPT LANGUAGE="JavaScript">eval("x61x6Cx65x72x74x28x22u9ED1u5BAx29xT3B)"

>







Three: Use the script encoder Script Encoder produced by Microsoft for encoding. The use of the

tool will not be introduced much! I directly use JavaScript to call the control Scripting.Encoder to complete the encoding! The code is as follows: <SCRIPT LANGUAGE="JavaScript"> var Senc=newActiveXObject("Scripting.Encoder");

var code='<SCRIPTLANGUAGE="JavaScript">rnalert("Hacker Defense Line");rn</SCRIPT>'; varEncode =Senc.EncodeScriptFile(".htm",code,0,"");alert(Encode);

</SCRIPT>

The result after encoding is as follows:

<SCRIPTLANGUAGE="JScript.Encode">#@~^FgAAAA==@ #@&ls DD`J Hacker Defense r#p@#@&FgMAAA==^#~@</SCRIPT>

Ugly enough to understand? But the corresponding decryption tools have already come out, and there are even decrypted web pages! Because there are too many codes for decrypting web pages, I won't say more about it! Let me introduce my original decryption code, as follows: <SCRIPT LANGUAGE="JScript.Encode"> functiondecode() alert(decode.toString());

</SCRIPT>



JAVASCRIPT simple source code encryption method:

Arbitrarily add a NUL null character (hex 00H). An accidental experiment made me find that adding any number of "null characters" anywhere in the HTML page, IE will still display the content normally, and execute the javascript code in it normally, and the added "null characters" we are in When viewed with a general editor, it will display spaces or black blocks, making the original code difficult to read. If viewed with Notepad, "empty characters" will become "spaces". Using this principle, the encryption results are as follows: (where The displayed "space" stands for "null character") <script language="JavaScript">

alert("I love it");

</script>

How about? Does it look messy? If you don't know the method, it's hard to think of removing the "null character" (00H) in it!



Useless content confusion and newline spaces TAB Dafa

In javascript code, we can add a lot of useless strings or numbers, as well as useless code and comment content, etc., so that the really useful code is buried in it, and the useful code can be added with newlines , spaces, and TAB, add a lot of newlines, spaces, and TABs, and normal strings can be wrapped with "", which will make the code difficult to understand! For example, the encrypted form is as follows:

<SCRIPTLANGUAGE="javascript">

"xajgxsadffgds";1234567890

625623216;var$=0;alert//@$%%&*()(&













@#%$^&%$96667r45fggbhytjty

*/

//window

)

;"#@$#%@#432hu";212351436 Self



-written encryption and decryption function method

The code is decrypted, and many VBS viruses use this method to encrypt themselves to prevent signature scanning! The following is a simple encryption and decryption function I wrote. The encryption code is as follows (refer to the file "encryption.htm" for details):

<SCRIPTLANGUAGE="javascript">

function compile(code)

{

varc=String.fromCharCode(code.charCodeAt(0 )+code.length);

for(var i=1;i<code.length;i++)

alert(escape(c));

}

compile('alert("I Love Together");')

</SCRIPT >



Running to get the encrypted result:

o%CD%D1%D7%E6%9CJ%u9EF3%uFA73%uF1D4%u14F1%u7EE1Kd The

corresponding encrypted and decrypted code is as follows:

<SCRIPT LANGUAGE="javascript">







var c=String.fromCharCode(code.charCodeAt(0)-code.length);

for(var i=1;i<code.length;i++)

return c;

}

eval(uncompile("o%CD%D1%D7 %E6%9CJ%u9EF3%uFA73%uF1D4%u14F1%u7EE1Kd"));

</SCRIPT>



[color=gray]Keywords: source code encryption, source code encryption, source code encryption, source code encryption, source code encryption, source code encryption, source code encryption, source code encryption, source code encryption, source code encryption, source code encryption, source code encryption, source code encryption, source code encryption, source code encryption, source code encryption, source code encryption, source code Encryption, source code encryption. [/color]

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326358624&siteId=291194637