A PHP source code encryption method and device
By disassembling the PHP source code and obfuscating bit operation encoding, encrypted code sequences are generated, and the problem of PHP source code encryption in the prior art is difficult or easy to crack, and high-security PHP source code encryption is achieved.
Patent Information
- Application Number
- CN202111049127.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-08
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2041-09-08
AI Technical Summary
In the prior art, PHP source code encryption is difficult or easy to crack, and the operation is complicated, and there is a problem of insufficient security.
By disassembling the PHP source code into single characters, the ASCII code for each single character is determined, and each ASCII code is processed through bit operation encoding obfuscation, and an encrypted code sequence is generated as the encrypted PHP code.
It improves the security of PHP source code, is difficult to be reverse cracked, and is relatively simple to operate, and is not easy to expose the code logic, meeting complex market needs.
Smart Images

Figure CN113742662B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a PHP source code encryption method and device. Background Art
[0002] PHP (Hypertext Preprocessor) has been rapidly promoted and applied in the Internet field due to its powerful functions, excellent efficiency, and easy learning. However, as an interpreted scripting language, PHP needs to directly read the source code to execute when the program is running. After the PHP program is installed and deployed, users can see the complete source code of the PHP program, which is prone to leakage.
[0003] To address this problem, the following three methods are usually used:
[0004] 1. Based on the extension or interface lib library provided by a third party;
[0005] 2. Directly obfuscate PHP variables, add encoding conversion, such as base64 conversion, code compression, Chinese traditional variable command mode, number 0 and character case o;
[0006] 3. Extension-based PHP source code encryption, the principle is to pre-encrypt the PHP source code through asymmetric or symmetric encryption, and then decrypt and run it before loading opcache.
[0007] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art: Method 1 requires payment of third-party fees and has low security; Method 2 is based on the conventional form of PHP source code obfuscation and is easily reverse cracked; Method 3 requires pre-installation of PHP extensions, which is more complicated to operate, and the source code can be obtained before loading opcache. Summary of the invention
[0008] In view of this, an embodiment of the present invention provides a PHP source code encryption method and device, which can at least solve the problem that PHP source code encryption is difficult or easy to crack in the prior art.
[0009] To achieve the above object, according to one aspect of an embodiment of the present invention, a PHP source code encryption method is provided, comprising:
[0010] Decompose the PHP source code into single characters and determine the ASCII code corresponding to each single character;
[0011] Each ASCII code is processed by bit operation coding obfuscation to obtain the encryption code corresponding to each single character;
[0012] According to the order of the single characters in the PHP source code, the obtained encryption codes are arranged and combined to generate an encryption code sequence, and the encryption code sequence is used as the encrypted PHP code.
[0013] Optionally, the bitwise encoding obfuscation method is used to process each ASCII code, including:
[0014] For the ASCII code of a single character, multiple ASCII codes are processed by bit operation to calculate the ASCII code of the single character;
[0015] The multiple ASCII codes are sorted according to the bit operation order, and the symbols of the bit operation used are added between adjacent ASCII codes to obtain the encryption code of the single character.
[0016] Optionally, the step of arranging and combining the obtained encryption codes according to the order of the single characters further includes:
[0017] Add a preset separator between different encryption codes; or
[0018] From the array of preset ASCII code and delimiter mapping relationships, find the delimiter corresponding to the last ASCII code in each encryption code, and then add the delimiter between the corresponding encryption code and the next encryption code.
[0019] Optionally, after using the encryption code sequence as the encrypted PHP code, the method further includes:
[0020] Identifying a separator in the encryption code sequence to decompose the encryption code sequence into a plurality of encryption codes using the separator;
[0021] Perform bitwise operations on each encrypted code to obtain an ASCII code, and then convert each ASCII code into a single character;
[0022] According to the order of the encryption codes in the encryption code sequence, character concatenation is performed on the obtained single characters to generate the PHP source code.
[0023] Optionally, the identifying a separator in the encryption code sequence includes:
[0024] identifying the predetermined delimiter in the encryption code sequence; or
[0025] Based on the delimiters in the array, a delimiter in the encrypted code sequence is identified.
[0026] To achieve the above object, according to another aspect of an embodiment of the present invention, a PHP source code encryption device is provided, comprising:
[0027] The disassembly module is used to disassemble the PHP source code into single characters and determine the ASCII code corresponding to each single character;
[0028] The bit operation module is used to process each ASCII code by bit operation coding obfuscation to obtain the encryption code corresponding to each single character;
[0029] The sorting module is used to arrange and combine the obtained encryption codes according to the sorting between single characters in the PHP source code, generate an encryption code sequence, and use the encryption code sequence as the encrypted PHP code.
[0030] Optionally, the bit operation module is used to:
[0031] For the ASCII code of a single character, multiple ASCII codes are processed by bit operation to calculate the ASCII code of the single character;
[0032] The multiple ASCII codes are sorted according to the bit operation order, and the symbols of the bit operation used are added between adjacent ASCII codes to obtain the encryption code of the single character.
[0033] Optionally, the sorting module is used to:
[0034] Add a preset separator between different encryption codes; or
[0035] From the array of preset ASCII code and delimiter mapping relationships, find the delimiter corresponding to the last ASCII code in each encryption code, and then add the delimiter between the corresponding encryption code and the next encryption code.
[0036] Optionally, a decryption module is further included, which is used to: identify a separator in the encryption code sequence, so as to use the separator to decompose the encryption code sequence into multiple encryption codes;
[0037] Perform bitwise operations on each encrypted code to obtain an ASCII code, and then convert each ASCII code into a single character;
[0038] According to the order of the encryption codes in the encryption code sequence, character concatenation is performed on the obtained single characters to generate the PHP source code.
[0039] Optionally, the decryption module is used to:
[0040] identifying the predetermined delimiter in the encryption code sequence; or
[0041] Based on the delimiters in the array, a delimiter in the encrypted code sequence is identified.
[0042] To achieve the above objective, according to another aspect of an embodiment of the present invention, a PHP source code encryption electronic device is provided.
[0043] The electronic device of an embodiment of the present invention includes: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors implement any of the above-mentioned PHP source code encryption methods.
[0044] To achieve the above-mentioned purpose, according to another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, any of the above-mentioned PHP source code encryption methods is implemented.
[0045] According to the solution provided by the present invention, an embodiment of the above invention has the following advantages or beneficial effects: ASCII code is processed by bit operation encoding obfuscation, one character corresponds to one BAC code, and the number of ASCII codes and the bit operation method used are diverse; after obtaining the BAC code sequence, the PHP source code is obtained by reverse parsing using the anti-encryption method. This protection method has high security, is not easy to expose code logic, and thus is not easy to discover logical vulnerabilities, thus meeting complex market needs.
[0046] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0048] Figure 1 This is a schematic diagram of the main process of a PHP source code encryption method according to an embodiment of the present invention;
[0049] Figure 2 It is a schematic diagram of a BAC code sequence;
[0050] Figure 3 It is a flow chart of a PHP source code encryption and decryption method according to an embodiment of the present invention;
[0051] Figure 4 This is a schematic diagram of main modules of a PHP source code encryption device according to an embodiment of the present invention;
[0052] Figure 5 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0053] Figure 6 It is a schematic diagram of the structure of a computer system of a mobile device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0054] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0055] The following are the explanations for the terms involved in this plan:
[0056] PHP is a scripting language that is executed on the server side, especially suitable for web development and can be embedded in HTML. PHP syntax makes use of C, Java and Perl, and the main goal of the language is to allow web developers to quickly write dynamic web pages.
[0057] Opcache is a method of avoiding the overhead of loading and parsing PHP scripts each time by storing the precompiled bytecode (Operate Code) of the parsed PHP script in shared memory. The parser can directly read the cached bytecode (Operate Code) from the shared memory, thereby greatly improving the execution efficiency of PHP.
[0058] See also Figure 1 , which shows a main flow chart of a PHP source code encryption method provided by an embodiment of the present invention, comprising the following steps:
[0059] S101: Decompose the PHP source code into single characters, and determine the ASCII code corresponding to each single character;
[0060] S102: Process each ASCII code by bit operation coding obfuscation to obtain an encryption code corresponding to each single character;
[0061] S103: Arrange and combine the obtained encryption codes according to the order of the single characters in the PHP source code to generate an encryption code sequence, and use the encryption code sequence as the encrypted PHP code.
[0062] In the above implementation, for step S101, the PHP source code is first disassembled into single characters, and each single character corresponds to only one ASCII code. It should be noted that the ASCII code can be in binary, decimal or hexadecimal form, but only one system can be used for the same PHP source code, such as using hexadecimal ASCII code. Among them, ASCII code (American Standard Code for Information Interchange) is a computer coding system based on Latin letters, mainly used to display modern English and other Western European languages.
[0063] For step S102, a bit operation method is predefined, as shown in Table 1:
[0064] Table 1
[0065]
[0066] As shown in Table 2, the character "v" in the source code is converted into the ASCII code "\x56". Different ASCII code combinations can be converted into "\x56" through multiple attempts, such as "″^″4″|′B′", whose operation result is equal to "\x56". Therefore, "″^″4″|′B′" is used as the encryption code of the character "v", that is, the BAC code. It should be noted that the "″^″4″|′B′" here needs to include multiple ASCII codes and the bit operations used, such as the above-mentioned "^" and "|", and the order between the ASCII codes cannot be changed.
[0067] Table 2 BAC code: B corresponds to bit operation, A corresponds to ASCII code, and C is obfuscation
[0068] Source code ASCII Code After bitwise coding confusion (BAC code for short) V \x56 ″^″4″|′B′ _ \x5F ″Y″|″A″^″\x46″ D \x44 ″d″^″″ ( \x28 ″e″^″x4D″ ; \x3B ″K″^″p″
[0069] The above method converts an original ASCII code that is easy to know into a BAC code that is not easy to crack. The ASCII code and the bit operation method used in the BAC code are uncontrollable, which provides a variety of permutations and combinations for PHP source code obfuscation, thereby improving the encryption effect and effectively preventing PHP source code leakage.
[0070] For step S103, the obtained BAC codes can be arranged and combined according to the order of the single characters in the PHP source code to generate a BAC code sequence. Considering the uncertainty of the number of ASCII codes in each BAC code, a separator can be further used to separate different BAC codes for subsequent analysis and use. The final result can be seen in Figure 2 As shown:
[0071] 1) The separator is fixed, that is, a preset separator is added between different BAC codes, which is the simplest separator definition, such as "^";
[0072] 2) Calculate the separator through the HASH algorithm: predefine an array of ASCII code and separator mapping relationship, for example, ASCII code "d" corresponds to separator "<>", read the last ASCII code in each BAC code, and find the corresponding separator "<>" when reading ASCII code "d", and then add the separator "<>" between the BAC code and the next BAC code.
[0073] The final PHP source code and BAC code sequence are compared as follows:
[0074] PHP function: VAR_DUMP(1);
[0075] BAC code sequence: ″^″4″|′B′^″\x2D″^′[′^′7′^″\x2E″^″\x7C″^″Y″|″A″^″\x46″^″d″^″″^″d″^″1″^″\x6E″^″#″^″y″^″)″^″e″^″\x4D″^″e″^″\x4C″^″K″^″p″
[0076] The method provided in the above embodiment processes ASCII code through bit operation coding obfuscation. One character corresponds to one BAC code. The number of ASCII codes and the bit operation method used are diverse, which improves the obfuscation encryption effect of PHP source code, and it is difficult to crack even if it is obtained.
[0077] See also Figure 3 , shows a schematic flow chart of a PHP source code encryption and decryption method according to an embodiment of the present invention, comprising the following steps:
[0078] S301: Decompose the PHP source code into single characters, and determine the ASCII code corresponding to each single character;
[0079] S302: for the ASCII code of a single character, processing multiple ASCII codes by bit operation to calculate the ASCII code of the single character;
[0080] S303: sorting the multiple ASCII codes according to the bit operation order, and adding the used bit operation symbol between adjacent ASCII codes to obtain the encryption code of the single character;
[0081] S304: Adding a preset separator between different encryption codes;
[0082] S305: searching for a separator corresponding to the last ASCII code in each encryption code from an array of preset ASCII code and separator mapping relationships, and then adding the separator between the corresponding encryption code and the next encryption code;
[0083] S306: Arrange and combine the obtained encryption codes according to the order of the single characters in the PHP source code to generate an encryption code sequence, and use the encryption code sequence as the encrypted PHP code;
[0084] S307: Identify a separator in the encryption code sequence, and use the separator to decompose the encryption code sequence into multiple encryption codes;
[0085] S308: Perform bitwise operation on each encryption code to obtain an ASCII code, and then convert each ASCII code into a single character;
[0086] S309: According to the order of the encryption codes in the encryption code sequence, character concatenation is performed on the obtained single characters to generate the PHP source code.
[0087] In the above embodiment, for steps S301 to S306, see Figure 1 The description of steps S101 to S103 is not repeated here.
[0088] In the above implementation, for step S307, the previous implementation mainly describes how to encrypt the PHP source code, and this implementation mainly describes how to decrypt and obtain the PHP source code.
[0089] Since the BAC code sequence is composed of multiple BAC codes, it is first necessary to use the separators between the BAC codes to disassemble the BAC code sequence into multiple BAC codes. Specifically, in the case of only using the preset separator, the preset separator is used to disassemble the BAC code. However, in the case of using an array, it is necessary to first determine the separator in the array to identify the separator and its position in the BAC code sequence, and then use the separator to disassemble the BAC code. For example, the mapping relationship between the preset ASCII code "d" and the separator "<>" in the data, the separator "<>" is identified from the BAC code sequence, and the BAC code where the ASCII code "d" is located is separated from the next BAC code by the separator.
[0090] For step S308, each BAC code is composed of multiple ASCII codes arranged in a positioning operation manner, such as the aforementioned "″Y″|″A″^″\x46″", the first ASCII code is Y, the second ASCII code is A, and the third ASCII code is \x46, where Y and A are "OR operated" and the calculation result and \x46 are "XOR operated".
[0091] Therefore, after the BAC code sequence is decomposed into multiple BAC codes, each BAC code needs to be processed by bit operation, such as the bit operation of the above-mentioned "″Y″|″A″^″\x46″", and the result "\x5F" is calculated, and then "\x5F" is converted into character form.
[0092] For step S309, the order between single characters is the order of BAC codes in the BAC code sequence. Therefore, after obtaining the single character, the characters will be spliced according to the order between BAC codes in the BAC code sequence to generate PHP source code, and then executed by PHP's built-in function EVAL (BAC parsing function (BAC)).
[0093] Part of the core code is encrypted and obfuscated, and finally the PHP function is implemented (the actual PHP source code executed is VAR_DUMP(1);)
[0094] $v=″^″4″|′B′;
[0095] $a=″\x2D″^′[′^′7′;
[0096] $r = "\x2E"^"\x7C";
[0097] $_=″Y″|″A″^″\x46″;
[0098] $d=″d″^″″;
[0099] $u=″d″^″1″;
[0100] $m=″\x6E″^″#″;
[0101] $n=″y″^″)″;
[0102] $(=″e″^″\x4D″;
[0103] $)=″e″^″\x4C″;
[0104] $; = "K"^"p";
[0105] eval(enbac(″^″4″|′B′^″\x2D″^′[′^′7′^″\x2E″^″\x7C″^″Y″|″A″^″\x46″^ ″d″^″″^″d″^″1″^″\x6E″^″#″^″y″^″)″^″e″^″\x4D″^″e″^″\x4C″^″K″^″p″));
[0106] The method provided in the above embodiment, after obtaining the BAC code sequence, uses the anti-encryption method to perform reverse parsing to obtain the PHP source code. This protection method has high security, is not easy to expose the code logic, and is not easy to discover logical vulnerabilities, thus meeting complex market needs.
[0107] The method provided by the embodiment of the present invention has at least the following beneficial effects compared with the prior art:
[0108] 1. Using PHP's weak type feature, perform different bit operations on different ASCII codes to increase the intensity of obfuscation and the difficulty of cracking. Weak type is a feature of programming languages. The underlying language will convert variable types, and there is no need to develop code to convert the corresponding types.
[0109] 2. Based on the ASCII 127 codes, the BAC code is arranged and combined to make it more diverse, so that the PHP code is not easy to be cracked, thereby improving the security of the PHP source code;
[0110] 3. The whole system can be cross-platform without the need for a third party, and uses PHP extensions for encryption and decryption, without the risk of source code leakage.
[0111] See also Figure 4 , showing a schematic diagram of main modules of a PHP source code encryption device 400 provided in an embodiment of the present invention, including:
[0112] The disassembly module 401 is used to disassemble the PHP source code into single characters and determine the ASCII code corresponding to each single character;
[0113] The bit operation module 402 is used to process each ASCII code by bit operation coding obfuscation to obtain the encryption code corresponding to each single character;
[0114] The sorting module 403 is used to arrange and combine the obtained encryption codes according to the sorting between single characters in the PHP source code, generate an encryption code sequence, and use the encryption code sequence as the encrypted PHP code.
[0115] In the device of the embodiment of the present invention, the bit operation module 402 is used to:
[0116] For the ASCII code of a single character, multiple ASCII codes are processed by bit operation to calculate the ASCII code of the single character;
[0117] The multiple ASCII codes are sorted according to the bit operation order, and the symbols of the bit operation used are added between adjacent ASCII codes to obtain the encryption code of the single character.
[0118] In the device of the embodiment of the present invention, the sorting module 403 is used to:
[0119] Add a preset separator between different encryption codes; or
[0120] From the array of preset ASCII code and delimiter mapping relationships, find the delimiter corresponding to the last ASCII code in each encryption code, and then add the delimiter between the corresponding encryption code and the next encryption code.
[0121] The device of the embodiment of the present invention further includes a decryption module, which is used to:
[0122] Identifying a separator in the encryption code sequence to decompose the encryption code sequence into a plurality of encryption codes using the separator;
[0123] Perform bitwise operations on each encrypted code to obtain an ASCII code, and then convert each ASCII code into a single character;
[0124] According to the order of the encryption codes in the encryption code sequence, character concatenation is performed on the obtained single characters to generate the PHP source code.
[0125] In the device of the embodiment of the present invention, the decryption module is used to:
[0126] identifying the predetermined delimiter in the encryption code sequence; or
[0127] Based on the delimiters in the array, a delimiter in the encrypted code sequence is identified.
[0128] In addition, the specific implementation content of the device described in the embodiment of the present invention has been described in detail in the method described above, so the repeated content will not be described again here.
[0129] Figure 5 An exemplary system architecture 500 to which embodiments of the present invention may be applied is shown, including terminal devices 501 , 502 , 503 , a network 504 and a server 505 (only an example).
[0130] Terminal devices 501, 502, 503 can be various electronic devices with display screens and supporting web browsing, and various communication client applications are installed. Users can use terminal devices 501, 502, 503 to interact with server 505 through network 504 to receive or send messages, etc.
[0131] The network 504 is used to provide a medium for communication links between the terminal devices 501, 502, 503 and the server 505. The network 504 may include various connection types, such as wired, wireless communication links or optical fiber cables.
[0132] Server 505 may be a server that provides various services, and is used to perform operations such as disassembling PHP source code, converting single characters into ASCII codes, converting ASCII codes into BAC codes, and combining and generating BAC code sequences, and decryption operations.
[0133] It should be noted that the method provided in the embodiment of the present invention is generally executed by the server 505 , and accordingly, the device is generally set in the server 505 .
[0134] It should be understood that Figure 5 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0135] Reference below Figure 6 , which shows a schematic diagram of the structure of a computer system 600 of a terminal device suitable for implementing an embodiment of the present invention. Figure 6 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0136] like Figure 6As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage part 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the system 600 are also stored. The CPU 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0137] The following components are connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage section 608 as needed.
[0138] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the central processing unit (CPU) 601, the above-mentioned functions defined in the system of the present invention are executed.
[0139] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0140] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0141] The modules involved in the embodiments of the present invention may be implemented by software or hardware. The modules described may also be set in a processor, for example, it may be described as: a processor includes a disassembly module, a bit operation module, and a sorting module. The names of these modules do not constitute a limitation on the modules themselves in some cases, for example, the sorting module may also be described as an "encryption code sorting module".
[0142] As another aspect, the present invention further provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes:
[0143] Decompose the PHP source code into single characters and determine the ASCII code corresponding to each single character;
[0144] Each ASCII code is processed by bit operation coding obfuscation to obtain the encryption code corresponding to each single character;
[0145] According to the order of the single characters in the PHP source code, the obtained encryption codes are arranged and combined to generate an encryption code sequence, and the encryption code sequence is used as the encrypted PHP code.
[0146] According to the technical solution of the embodiment of the present invention, at least the following beneficial effects are achieved:
[0147] 1. Using PHP's weak type feature, perform different bit operations on different ASCII codes to increase the intensity of obfuscation and the difficulty of cracking. Weak type is a feature of programming languages. The underlying language will convert variable types, and there is no need to develop code to convert the corresponding types.
[0148] 2. Based on the ASCII 127 codes, the BAC code is arranged and combined to make it more diverse, so that the PHP code is not easy to be cracked, thereby improving the security of the PHP source code;
[0149] 3. The whole system can be cross-platform without the need for a third party, and uses PHP extensions for encryption and decryption, without the risk of source code leakage.
[0150] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A PHP source code encryption method, characterized in that: include: Decompose the PHP source code into single characters and determine the ASCII code corresponding to each single character; Processing each ASCII code by bit operation coding obfuscation to obtain an encryption code corresponding to each single character, including: for the ASCII code of a single character, processing multiple ASCII codes by bit operation to calculate the ASCII code of the single character; Sort the multiple ASCII codes according to the bit operation order, and add the used bit operation symbol between adjacent ASCII codes to obtain the encryption code of the single character; According to the order of the single characters in the PHP source code, the obtained encryption codes are arranged and combined to generate an encryption code sequence, and the encryption code sequence is used as the encrypted PHP code.
2. The method according to claim 1, characterized in that Arrange and combine the obtained encryption codes according to the order of the single characters, and also include: Add a preset separator between different encryption codes; or From the array of preset ASCII code and delimiter mapping relationships, find the delimiter corresponding to the last ASCII code in each encryption code, and then add the delimiter between the corresponding encryption code and the next encryption code.
3. The method according to claim 2, characterized in that After using the encrypted code sequence as the encrypted PHP code, the method further includes: Identifying a separator in the encryption code sequence to decompose the encryption code sequence into a plurality of encryption codes using the separator; Perform bitwise operations on each encrypted code to obtain an ASCII code, and then convert each ASCII code into a single character; According to the order of the encryption codes in the encryption code sequence, character concatenation is performed on the obtained single characters to generate the PHP source code.
4. The method according to claim 3, characterized in that The identifying the delimiter in the encryption code sequence includes: identifying the predetermined delimiter in the encryption code sequence; or Based on the delimiters in the array, a delimiter in the encrypted code sequence is identified.
5. A PHP source code encryption device, characterized in that: include: The disassembly module is used to disassemble the PHP source code into single characters and determine the ASCII code corresponding to each single character; The bit operation module is used to process each ASCII code by bit operation coding obfuscation to obtain the encryption code corresponding to each single character, including: for the ASCII code of a single character, processing multiple ASCII codes by bit operation to calculate the ASCII code of the single character; sorting the multiple ASCII codes according to the bit operation order, and adding the used bit operation symbol between adjacent ASCII codes to obtain the encryption code of the single character; The sorting module is used to arrange and combine the obtained encryption codes according to the sorting between single characters in the PHP source code, generate an encryption code sequence, and use the encryption code sequence as the encrypted PHP code.
6. The device according to claim 5, characterized in that The sorting module is used to: Add a preset separator between different encryption codes; or From the array of preset ASCII code and delimiter mapping relationships, find the delimiter corresponding to the last ASCII code in each encryption code, and then add the delimiter between the corresponding encryption code and the next encryption code.
7. The device according to claim 6, characterized in that Also includes a decryption module for: Identifying a separator in the encryption code sequence to decompose the encryption code sequence into a plurality of encryption codes using the separator; Perform bitwise operations on each encrypted code to obtain an ASCII code, and then convert each ASCII code into a single character; According to the order of the encryption codes in the encryption code sequence, character concatenation is performed on the obtained single characters to generate the PHP source code.
8. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 4.
9. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Encryption method and device, decryption method and device, electronic equipment and medium
CN110737908A
Encryption and decryption method and device based on random hash and bit operation
WO2020168628A1