Encrypt the code into garbled characters? Let's hide the code!

Source: Internet
Author: User

 

First, I declare that there is no practical value for entertainment... Light spray.

 

Today, I saw this blog by Chen Hao Daniel during the online shopping spree: http://coolshell.cn/articles/1142.html

I feel like what I saidWhitespace LanguageVery interesting. Wikipedia-http://zh.wikipedia.org/wiki/Whitespace

In general programming languages, blank characters are ignored, while whitespace only recognizes blank characters. The advantage is that "code printing cannot be taken away "...

 

Although I don't know whether anyone really uses this language for project development, this gives us the idea: encrypt the code into blank characters.

Then I wrote one in C language with simple functions, mainly as follows:

1. encrypt and decrypt any text

2. Execute the encrypted Lua code

 

For example, The Lua version's hello World encryption is like this:

 1                                                                                                                  2    3                                      4       5        6                                                                                                                                                                                                                                                                                                                  7                          8                                        9                              10        11 12    13                                                                                                                                                                                                                                                                                                                             14                                                        15                         16    17                         18                                 19                                                                                                                                                                                                                                                                         20        
View code

You said you couldn't see it? Of course, dummies are invisible. (Joke, by the Emperor's New Clothes...)

 

Name the program white for the time being. Enter the following code in the console:

Encryption:

White-encode [source file] [output file]

Decryption:

White-Decode [source file] [output file]

Encrypted Files:

White-run [source file]

 

The C language code I just wrote is attached. It is very simple to write. The return values of the function are bool. When the execution fails, false is returned. Obviously, I did not write a line of error processing, returns true directly, which is more streamlined...

1 # DEFINE _ crt_secure_no_warnings 2 3 # include <stdio. h> 4 # include <stdlib. h> 5 # include <string. h> 6 extern "C" {7 # include <Lua. h> 8 # include <lauxlib. h> 9 # include <lualib. h> 10} 11 12 // read content from the file 13 bool readfromfile (const char * filename, char * & content) 14 {15 auto file = fopen (filename, "R"); 16 fseek (file, 0, seek_end); 17 auto filesize = ftell (File); 18 fseek (file, 0, seek_set); 19 cont Ent = (char *) malloc (filesize * sizeof (char); 20 fread (content, sizeof (char), filesize, file); 21 fclose (File ); 22 content [filesize] = 0; 23 return true; 24} 25 26 // write the content to file 27 bool writetofile (const char * filename, const char * content) 28 {29 auto file = fopen (filename, "W"); 30 int filesize = 0; 31 While (content [filesize]! = 0) {32 filesize ++; 33} 34 fwrite (content, sizeof (char), filesize, file); 35 fclose (File); 36 return true; 37} 38 39 // encrypt 40 bool encode (const char * SRC, char * TAR) 41 {42 int COUNT = 0; 43 char pointer = 0; 44 For (INT I = 0; SRC [I]! = 0; I ++) {45 char cur = SRC [I]; 46 for (; pointer <cur; pointer ++) {47 tar [count ++] = ''; 48} 49 for (; pointer> cur; Pointer --) {50 tar [count ++] = '\ T '; 51} 52 tar [count ++] = '\ n'; 53} 54 tar [count] = 0; 55 return true; 56} 57 58 // decrypt 59 bool decode (const char * SRC, char * TAR) 60 {61 int COUNT = 0; 62 char CH = 0; 63 for (INT I = 0; SRC [I]! = 0; I ++) {64 switch (SRC [I]) {65 case '': 66 ch ++; break; 67 case '\ t': 68 ch --; break; 69 case '\ N': 70 tar [count ++] = CH; 71} 72} 73 tar [count] = 0; 74 return true; 75} 76 77 int main (INT argc, char * argv []) 78 {79 if (strcmp (argv [1], "-encode") = 0) {80 char * content = nullptr; 81 char ch_encode [1024*8]; 82 readfromfile (argv [2], content); 83 encode (content, ch_encode ); 84 writetofile (argv [3], ch_encode); 85} 86 else if (strcmp (argv [1], "-decode") = 0) {87 char * content = nullptr; 88 char ch_decode [1024*8]; 89 readfromfile (argv [2], content); 90 decode (content, ch_decode ); 91 writetofile (argv [3], ch_decode); 92} 93 else if (strcmp (argv [1], "-Run") = 0) {94 char * content = nullptr; 95 char ch_decode [1024*8]; 96 readfromfile (argv [2], content); 97 decode (content, ch_decode ); 98 lua_state * l = lual_newstate (); 99 lual_openlibs (l); 100 lual_dostring (L, ch_decode); 101 lua_close (l); 102} 103 return 0; 104}
View code

 

In addition, the Lua source code needs to be written in a line. You can press Ctrl + F to replace the carriage return. Please advise how to use lual_dostring () to execute multiple lines of code at a time.

Encrypt the code into garbled characters? Let's hide the code!

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.