A compilation method, device, equipment, medium and product

By compiling the source code of an interpreted language into encrypted bytecode and decrypting and executing it at runtime, the problem that the source code of an interpreted language is easily read and tampered with, and the security of the application is improved.

CN114925338BActive Publication Date: 2024-12-31DOUYIN VISION CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210506072.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-10
Publication Date
2024-12-31
Estimated Expiration
2042-05-10

AI Technical Summary

Technical Problem

When developing applications in interpreted languages, the source code is easily read and tampered with, resulting in security risks.

Method used

Precompile the source code of an interpreted language into bytecode, and generate dynamic or static link libraries through encryption and hiding, using the code runner to decrypt and execute bytecode at runtime to prevent illegal source code and program logic Read and tamper.

Benefits of technology

It effectively prevents attackers from obtaining and tampering with source code and program logic, and improves application security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114925338B_ABST
    Figure CN114925338B_ABST
Patent Text Reader

Abstract

The present disclosure discloses a compilation method, device, equipment, medium and product. The method includes: compiling the original source code acquired in advance into the original bytecode, wherein the original source code is an interpreted language; generating the corresponding dynamic link library or static link library according to the original bytecode encryption bytecode and the pre-acquired native code template; in response to the running operation of the program, reading and decrypting the encrypted bytecode in the dynamic link library or static link library to obtain the decrypted bytecode; calling the pre-created code runner to run the decrypted bytecode. The technical solution disclosed in the present disclosure, by pre-compiling the original source code of the interpreted language into the original bytecode and encrypting it, implements the code decryption and code running logic in the pre-created dynamic link library or static link library, and calls the code runner to run the decrypted bytecode, so that the attacker cannot obtain the source code and program logic, and cannot conduct illegal reading and tampering.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a compilation method, apparatus, device, medium and product. Background Art

[0002] With the continuous development of computers, different types of languages ​​(such as interpreted languages, compiled languages, etc.) can be used to develop applications.

[0003] When using interpreted languages ​​to develop applications, it means that the source code must be included when the program is distributed. Cracking the application by reading the source code poses a great risk to the product. Therefore, how to prevent the source code from being read and tampered with is an urgent problem to be solved. Summary of the invention

[0004] The present disclosure provides a compilation method, apparatus, device, medium and product to solve the problem of source code being read and tampered in the prior art, and can compile, encrypt and hide the source code in advance, thereby preventing the source code from being read and tampered.

[0005] According to one aspect of the present disclosure, there is provided a compilation method, comprising:

[0006] Compiling the original source code obtained in advance into corresponding original bytecode; wherein the original source code is an interpreted language;

[0007] Generate a corresponding dynamic link library or static link library according to the encrypted bytecode corresponding to the original bytecode and a pre-acquired native code template;

[0008] In response to the running operation of the program, reading and decrypting the encrypted bytecode in the dynamic link library or the static link library to obtain the decrypted bytecode;

[0009] The pre-created code runner is called to run the decrypted bytecode.

[0010] According to another aspect of the present disclosure, a compiling device is provided, comprising:

[0011] A compiling module, used to compile the original source code acquired in advance into the corresponding original bytecode; wherein the original source code is an interpreted language;

[0012] A generation module, used to generate a corresponding dynamic link library or static link library according to the encrypted bytecode corresponding to the original bytecode and a pre-acquired native code template;

[0013] A decryption module, used for reading and decrypting the encrypted bytecode in the dynamic link library or the static link library in response to the running operation of the program to obtain the decrypted bytecode;

[0014] The calling and running module is used to call a pre-created code runner to run the decrypted bytecode.

[0015] According to another aspect of the present disclosure, an electronic device is provided, the electronic device comprising:

[0016] at least one processor; and

[0017] a memory communicatively connected to the at least one processor; wherein,

[0018] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the compilation method described in any embodiment of the present disclosure.

[0019] According to another aspect of the present disclosure, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the compilation method described in any embodiment of the present disclosure when executed.

[0020] According to another aspect of the present disclosure, a computer program product is provided. The computer program product includes a computer program. When the computer program is executed by a processor, the compiling method described in any embodiment of the present disclosure is implemented.

[0021] The technical solution of the disclosed embodiment is to pre-compile the original source code of the interpreted language into the corresponding original bytecode, then encrypt the original bytecode, and generate the corresponding dynamic link library or static link library according to the encrypted bytecode and the pre-acquired native code template; then implement the logic of code decryption and code running in the dynamic link library or static link library, and call the code runner to run the decrypted bytecode, so that the attacker cannot obtain the source code and program logic, and cannot illegally read and tamper with the source code and program logic.

[0022] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0024] Figure 1A flowchart of a compilation method provided by an embodiment of the present disclosure;

[0025] Figure 2 A flowchart of another compilation method provided by an embodiment of the present disclosure;

[0026] Figure 3 A schematic diagram of the structure of a compiling device provided in an embodiment of the present disclosure;

[0027] Figure 4 It is a structural schematic diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION

[0028] In order to enable those skilled in the art to better understand the scheme of the present disclosure, the technical scheme in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in the field without creative work should fall within the scope of protection of the present disclosure.

[0029] It should be noted that the terms "original", "encrypted", "decrypted", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0030] In one embodiment, Figure 1 This is a flowchart of a compilation method provided by an embodiment of the present disclosure. This embodiment is applicable to the case of protecting source code. The method can be executed by a compilation device. The compilation device can be implemented in the form of hardware and / or software. The compilation device can be configured in an electronic device. Figure 1 As shown, the method includes:

[0031] S110, compile the original source code obtained in advance into corresponding original bytecode.

[0032] Among them, the original source code is an interpreted language. In an embodiment, the source code refers to an uncompiled text file written in accordance with a certain programming language specification, which is a readable computer language instruction. In an embodiment, the original source code can be an interpreted language. In an embodiment, the original source code can be pre-compiled by a pre-configured compilation module to obtain the corresponding bytecode as the original bytecode. Of course, in the actual compilation process, the operating environment of the original source code can be different, and the corresponding compilation modules used can also be different. Exemplarily, when the operating environment corresponding to the original source code is environment 1, the compilation module 1 can be used to compile the original source code to obtain the corresponding bytecode; for example, when the operating environment corresponding to the original source code is environment 2, the compilation module 2 can be used to compile the original source code to obtain the corresponding bytecode. It should be noted that in different operating environments, the compilation modules used can be compilation modules of the same type or different types.

[0033] S120: Generate a corresponding dynamic link library or static link library according to the encrypted bytecode corresponding to the original bytecode and the pre-acquired native code template.

[0034] The encrypted bytecode refers to the bytecode obtained by encrypting the original bytecode. It can be understood that the original bytecode is encrypted by a preset encryption algorithm to obtain the corresponding encrypted bytecode. In the actual encryption process, the encryption algorithm can be customized according to the business corresponding to the original source code, and the original bytecode is encrypted by the encryption algorithm to obtain the corresponding encrypted bytecode.

[0035] The native code template refers to a native code file that can be used to store bytecodes. Exemplarily, the native code template can be a code file in C language or a code file in other programming languages. In an embodiment, a native code template is obtained in advance, and then all data of the files corresponding to all encrypted bytecodes corresponding to the original bytecode are inserted into the pre-obtained native code template, and the corresponding dynamic link library or static link library is compiled. The dynamic link library refers to the DLL file; the static link library refers to the lib file.

[0036] In an embodiment, a pre-configured native code generator may be used to compile the native code template to obtain a corresponding dynamic link library or static link library.

[0037] S130. In response to the running operation of the program, read and decrypt the encrypted bytecode in the dynamic link library or the static link library to obtain the decrypted bytecode.

[0038] In an embodiment, the encrypted bytecode in the dynamic link library or the static link library is read, and the encrypted bytecode is decrypted using a preset decryption algorithm to obtain the corresponding decrypted bytecode. It should be noted that the preset encryption algorithm used for the original bytecode and the preset decryption algorithm used for the encrypted bytecode can be a symmetric key or a reversible encryption algorithm such as an asymmetric key, and this is not limited. It can be understood that when a symmetric key is used for decryption, the encryption key and the decryption key are the same; when an asymmetric key is used for decryption, the encryption key and the decryption key are different.

[0039] S140: Call a pre-created code runner to run the decrypted bytecode.

[0040] Wherein, the code runner refers to a module that can load a dynamic link library or a static link library. In an embodiment, a dynamic link library or a static link library can be loaded in the code runner to call an operation function to run the decrypted bytecode.

[0041] The technical solution of the disclosed embodiment is to pre-compile the original source code of the interpreted language into the corresponding original bytecode, then encrypt the original bytecode, and store the encrypted bytecode in a dynamic link library or a static link library; then implement the logic of code decryption and code running in the dynamic link library or the static link library, and call the code runner to run the decrypted bytecode, so that attackers cannot obtain the source code and program logic, and cannot illegally read and tamper with the source code and program logic.

[0042] In one embodiment, Figure 2 This is a flowchart of another compilation method provided by an embodiment of the present disclosure. This embodiment further illustrates the above steps based on the above embodiment. Figure 2 As shown, the method includes:

[0043] S210 . Compile the pre-acquired original source code using a pre-configured bytecode compiler to obtain corresponding original bytecode.

[0044] Among them, the original source code is the source code corresponding to one or more original source code files. In an embodiment, the bytecode compiler is a tool for compiling all source codes into bytecodes. It should be noted that the bytecode compiler can also be a code runner, wherein the code runner is a tool for loading and running dynamic link libraries or static link libraries. It can be understood that when the code runner has a compilation function, the code runner can be used as a bytecode compiler. In an embodiment, the original source code files can be compiled one by one to obtain the corresponding original bytecode; or multiple original source code files can be merged into one file for compilation to obtain the corresponding original bytecode. In an embodiment, the original source code is compiled using the bytecode compiler of the language used or the compilation function carried in the code runner to obtain the corresponding original bytecode.

[0045] It should be noted that when the operating environment corresponding to the original source code is a special environment (for example, Node.js), the code runner can be used to compile the original source code to obtain the corresponding original bytecode; when the operating environment corresponding to the original source code is a regular environment, the bytecode compiler can be directly used to compile the original source code to obtain the corresponding original bytecode.

[0046] S220. Determine an array declaration expression of a preset element type corresponding to the encrypted bytecode.

[0047] Among them, the preset element type refers to a pre-configured element type. Exemplarily, the preset element type can be a char type. In an embodiment, the data corresponding to the encrypted bytecode can be read into the memory, an array with an element type of char type can be obtained, and the array can be stored in the array declaration expression. Exemplarily, the encrypted bytecode can be converted into a string of [1,2,3,4], and then the string is used as a code snippet, and the corresponding data declaration expression is generated using the code snippet.

[0048] S230: Process the array declaration expression and the unique identification name of the bytecode corresponding to the encrypted bytecode to generate a corresponding code snippet.

[0049] In one embodiment, S230 includes:

[0050] S2301. Use the string of the unique identification name of the bytecode corresponding to the encrypted bytecode as the key, and use the array created by the array declaration expression as the value.

[0051] The unique identification name of the bytecode is used to characterize the unique identification of each bytecode. Exemplarily, the unique identification name of the bytecode can be the file relative path of the bytecode. The file relative path refers to the path relationship between the path where the file is located and other files. In an embodiment, the unique identification name of the bytecode corresponding to the encrypted bytecode is used as the key, and the array created by the array declaration expression is used as the value.

[0052] S2302. Combine the key and the value according to the preset data type to obtain a corresponding code snippet.

[0053] The preset data type refers to a Hash Map structure. Exemplarily, the preset data type may be std:map in the C++ standard library or dict in Python. In an embodiment, a string of a unique identification name of a bytecode corresponding to an encrypted bytecode is used as a key, and an array created by an array declaration expression is used as a value to obtain a key-value pair, and the key and value are combined according to the preset data type to obtain a corresponding code snippet.

[0054] For example, assuming that C++ is used as an example, the bytecode is stored in a HashMap and the following code snippet is generated:

[0055] std::map <std::string,

[0056] std::vector <char>>map;

[0057] map["bytecode1 unique identifier"] = bytecode1 content;

[0058] map["bytecode2 unique identifier"] = bytecode2 content;

[0059] S240: Insert the code snippet into the pre-acquired native code template, and compile to obtain a corresponding dynamic link library or static link library.

[0060] In one embodiment, the native code template includes at least the following functions: an encryption bytecode acquisition function; a decryption bytecode acquisition function. In an embodiment, the native code template needs to have a function of acquiring an encryption bytecode and a function of acquiring a decryption bytecode. In an embodiment, the encryption bytecode and decryption bytecode acquisition functions can be implemented by customizing the acquisition function, that is, a function for acquiring an encryption bytecode and a function for acquiring a decryption bytecode are customized.

[0061] The code snippet is inserted into an area in the native code template where code can be dynamically inserted, and a native code compiler is called to compile the native code template into which the code snippet has been dynamically inserted to obtain a corresponding dynamic link library or static link library.

[0062] S250: Determine a corresponding reading method according to the location of the encrypted bytecode in the dynamic link library or the static link library.

[0063] Wherein, the reading mode refers to the mode of reading the encrypted bytecode from the dynamic link library or the static link library. In the actual operation process, the encrypted bytecode can be stored in different locations, and accordingly, the reading mode of the encrypted bytecode can also be different. Exemplarily, the encrypted bytecode can be stored in the PE resource table, or can be stored as a constant in the executable file.

[0064] S260: Read the encrypted bytecode in the dynamic link library or the static link library according to the reading method.

[0065] In an embodiment, when the encrypted bytecode is stored in the PE resource table, the decrypted bytecode can be read using the LoadResource method; when the encrypted bytecode is stored as a constant in the executable file, the constant can be directly accessed to obtain the encrypted bytecode.

[0066] S270. Decrypt the encrypted bytecode using a preset decryption algorithm to obtain a decrypted bytecode.

[0067] The preset decryption algorithm can be a symmetric key or an asymmetric key with the preset encryption algorithm. Of course, if the preset decryption algorithm and the preset encryption algorithm use a symmetric key, the key used to decrypt the encrypted bytecode is the same as the key used to encrypt the original bytecode; if the preset decryption algorithm and the preset encryption algorithm use an asymmetric key, the key used to decrypt the encrypted bytecode is different from the key used to encrypt the original bytecode.

[0068] S280: Obtain the running function of the code runner to load the dynamic link library or the static link library.

[0069] In an embodiment, when a code runner is used to load a dynamic link library or a static link library, the code runner may expose some running functions and return to the loaded dynamic link library or static link library.

[0070] S290, run the decrypted bytecode by running the function.

[0071] In an embodiment, the decrypted bytecode is run through an exposed run function. Of course, the source code can also be run through the run function.

[0072] The technical solution of the disclosed embodiment, on the basis of the above-mentioned embodiment, triggers the steps of reading, decrypting and running the encrypted bytecode through the running function exposed when the code runner loads the dynamic link library or the static link library, thereby realizing the logic of code decryption and code running in the dynamic link library or the static link library, and calling the code runner to run the decrypted bytecode, so that the attacker cannot obtain the source code and the program logic, and cannot illegally read and tamper with the source code and the program logic.

[0073] In one embodiment, the implementation process of the code loader is described. In the embodiment, the code loader refers to a dynamic link library or a static link library developed in a native language (such as C++). It has two functions: storing encrypted bytecodes; decrypting and running bytecodes.

[0074] In an embodiment, the specific implementation process of the code loader includes:

[0075] S10, reading the encrypted bytecode stored in itself.

[0076] In an embodiment, there are many ways to read the encrypted bytecode. For example, for a dynamic link library under the Windows platform, if the encrypted bytecode is saved in the PF resource table, it can be read using the Load Resource method; if a code generator is used and the encrypted bytecode is saved as a constant in the native program code, the encrypted bytecode can be obtained by directly accessing this constant.

[0077] S11. After reading the encrypted bytecode, decrypt the encrypted bytecode to obtain the decrypted bytecode.

[0078] In the embodiment, there are many encryption and decryption methods, which can be customized according to the business in this solution. Simple ones include XOR encryption, and complex ones include Advanced Encryption Standard (AES) encryption.

[0079] S12. Call the code runner to run the decrypted bytecode.

[0080] In an embodiment, the interpreted language is run by a code runner, which can load a dynamic link library or a static link library when compiling. The code runner usually exposes some functions to the dynamic link library or static link library loaded by itself for running source code or bytecode. In this embodiment, the exposed running function is used to run the decrypted bytecode.

[0081] In an embodiment, the code loader is distributed in the form of a dynamic link library or a static link library, and usually exposes a run function for triggering the above-mentioned bytecode reading, decryption, and running steps. In an embodiment, as long as the "code loader" is loaded in the program running host (such as Electron or Node.js, which is used to run interpreted languages) and the above-mentioned run function is executed, the program logic can be run.

[0082] In one embodiment, the process of compiling a program is described. The compiler refers to a tool that compiles program source code into a usable code loader. In an embodiment, the compiler consists of the following three modules: a bytecode compiler; a native code generator; and a compilation tool or processing tool for the code loader.

[0083] First, the bytecode compiler is a tool that compiles all source code files into bytecode. Specifically, the implementation process of the bytecode compiler includes:

[0084] S21. If there are multiple source code files, you can merge the codes into one file for compilation, or you can compile the files one by one.

[0085] S22. Compile all source codes into bytecodes using the code compiler of the language used or the compilation function carried in the runner.

[0086] In an embodiment, compiling source code into bytecode is generally the job of a code compiler, except that some special operating environments, such as Node.js, compile source code into bytecode by writing code and running it in a code runner.

[0087] In one embodiment, native code is automatically generated based on the bytecode file generated by the bytecode compiler. The implementation process of the native code generator is described. Specifically, the implementation process of using the native code generator to obtain a dynamic link library or a static link library includes:

[0088] First, get a native code template that stores the bytecode.

[0089] In an embodiment, the native code template is generally a code file in C language, and may also be a file in other programming languages. The content of the template is the following content in the corresponding programming language:

[0090] First, define a function to obtain the encrypted bytecode, which is internally implemented as follows:

[0091] Defines a hash table; an area where code can be dynamically inserted, the code content is to add a key-value pair to the hash table; returns the hash table.

[0092] Second, define a function to obtain the decrypted bytecode, which is internally implemented as follows:

[0093] Call the encrypted bytecode function to obtain the encrypted bytecode; use the decryption method to decrypt the bytecode to obtain the original bytecode; return the original bytecode

[0094] Among them, the other code content is the implementation code of the "code loader".

[0095] Then, all the data of the bytecode file is read into the memory, and an array with the element type of char is obtained. The array is converted into an array declaration expression in the native programming language used (for example, it can be converted into a string of [1,2,3,4] in C language.

[0096] Then, the array declaration expression and the unique identifier of the bytecode (for example, the relative path of the bytecode file) are processed to generate a code snippet for inserting data into the hash table, with the unique identifier of the bytecode as the key and the array created by the array declaration expression as the value. The code snippet is then inserted into the "area where code can be dynamically inserted" in the native code template.

[0097] Finally, the native code compiler is called to compile the processed native code template to compile a dynamic link library or a static link library.

[0098] In this way, as long as the "code loader" is loaded in the code runner and the "run function" is called, the program code logic can be run normally. When distributing the program, you only need to distribute the "code runner" and "code loader". The code loader contains encrypted bytecode, and the decryption logic is difficult to decompile. In addition, the bytecode is more difficult to read and parse than the source code, which also plays a role in protecting the source code.

[0099] In one embodiment, Figure 3 A schematic diagram of the structure of a compiling device provided in an embodiment of the present disclosure. Figure 3 As shown, the device includes: a compiling module 310, a generating module 320, a decrypting module 330 and a calling and running module 340.

[0100] The compiling module 310 is used to compile the original source code acquired in advance into the corresponding original bytecode; wherein the original source code is an interpreted language;

[0101] A generation module 320, configured to generate a corresponding dynamic link library or a static link library according to the encrypted bytecode corresponding to the original bytecode and a pre-acquired native code template;

[0102] The decryption module 330 is used to read and decrypt the encrypted bytecode in the dynamic link library or the static link library in response to the running operation of the program to obtain the decrypted bytecode;

[0103] The calling and running module 340 is used to call a pre-created code runner to run the decrypted bytecode.

[0104] It should be noted that the decryption module 330 and the calling and running module 340, as logical units, can be included in a dynamic link library or a static link library. It can be understood that the encrypted bytecode is decrypted by the decryption module 330 included in the dynamic link library or the static link library to obtain the decrypted bytecode; and then the calling and running module 340 included in the dynamic link library or the static link library is used to call the code runner to run the decrypted bytecode.

[0105] Optionally, the compilation module 310 is specifically used to: compile the pre-acquired original source code through a pre-configured bytecode compiler or code runner to obtain the corresponding original bytecode; wherein the original source code is the source code corresponding to one or more original source code files.

[0106] Optionally, the generating module 320 includes:

[0107] A determination unit, used to determine an array declaration expression of a preset element type corresponding to the encrypted bytecode;

[0108] A generating unit, used for processing the array declaration expression and the unique identification name of the bytecode corresponding to the encrypted bytecode to generate a corresponding code snippet;

[0109] The compiling unit is used to insert the code snippet into a pre-acquired native code template, and compile to obtain a corresponding dynamic link library or static link library.

[0110] Optionally, the decryption module 330 includes:

[0111] A first determining unit, configured to determine a corresponding reading method according to a location of the encrypted bytecode in a dynamic link library or a static link library;

[0112] A reading unit, used for reading the encrypted bytecode in the dynamic link library or the static link library according to the reading method;

[0113] The decryption unit is used to decrypt the encrypted bytecode using a preset decryption algorithm to obtain a decrypted bytecode.

[0114] Optionally, calling the running module 340 includes:

[0115] An acquisition unit, used for acquiring an operation function of a code runner to load a dynamic link library or a static link library;

[0116] An execution unit is used to execute the decrypted bytecode through the execution function.

[0117] Optionally, the generating unit comprises:

[0118] Determine a subunit, which is used to use the string of the unique identification name of the bytecode corresponding to the encrypted bytecode as a key, and the array created by the array declaration expression as a value;

[0119] The generating subunit is used to combine the key and the value according to a preset data type to obtain a corresponding code snippet.

[0120] Optionally, the native code template includes at least the following functions: a function for obtaining an encrypted bytecode; and a function for obtaining a decrypted bytecode.

[0121] The compilation device provided in the embodiments of the present disclosure can execute the compilation method provided in any embodiment of the present disclosure, and has the functional modules and beneficial effects corresponding to the execution method.

[0122] In one embodiment, Figure 4 : is a schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.

[0123] like Figure 4 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0124] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0125] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as the compilation method.

[0126] In some embodiments, the compilation method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the compilation method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute the compilation method in any other appropriate manner (e.g., by means of firmware), including: compiling the pre-acquired original source code into the corresponding original bytecode; wherein the original source code is an interpreted language; generating a corresponding dynamic link library or static link library according to the encrypted bytecode corresponding to the original bytecode and the pre-acquired native code template; in response to the running operation of the program, reading and decrypting the encrypted bytecode in the dynamic link library or static link library to obtain the decrypted bytecode; calling the pre-created code runner to run the decrypted bytecode.

[0127] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0128] Computer programs for implementing the methods of the present disclosure may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0129] In the context of the present disclosure, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, device, or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, 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 foregoing.

[0130] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).

[0131] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0132] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.

[0133] According to one or more embodiments of the present disclosure, [Example 1] provides a compilation method, including:

[0134] Compiling the original source code obtained in advance into corresponding original bytecode; wherein the original source code is an interpreted language;

[0135] Generate a corresponding dynamic link library or static link library according to the encrypted bytecode corresponding to the original bytecode and a pre-acquired native code template;

[0136] In response to the running operation of the program, reading and decrypting the encrypted bytecode in the dynamic link library or the static link library to obtain the decrypted bytecode;

[0137] The pre-created code runner is called to run the decrypted bytecode.

[0138] According to one or more embodiments of the present disclosure, [Example 2] provides the method of Example 1, wherein compiling the pre-acquired original source code into the corresponding original bytecode includes:

[0139] The pre-acquired original source code is compiled by a pre-configured bytecode compiler or code runner to obtain the corresponding original bytecode; wherein the original source code is the source code corresponding to one or more original source code files.

[0140] According to one or more embodiments of the present disclosure, [Example 3] provides the method of Example 1, wherein the step of generating a corresponding dynamic link library or static link library according to the encrypted bytecode corresponding to the original bytecode and the pre-acquired native code template includes:

[0141] Determine an array declaration expression of a preset element type corresponding to the encrypted bytecode;

[0142] Processing the array declaration expression and the unique identification name of the bytecode corresponding to the encrypted bytecode to generate a corresponding code snippet;

[0143] The code snippet is inserted into a pre-acquired native code template, and compiled to obtain a corresponding dynamic link library or static link library.

[0144] According to one or more embodiments of the present disclosure, [Example 4] provides the method of Example 1, wherein the step of reading and decrypting the encrypted bytecode in the dynamic link library or the static link library to obtain the decrypted bytecode includes:

[0145] Determine a corresponding reading method according to the location of the encrypted bytecode in the dynamic link library or the static link library;

[0146] Read the encrypted bytecode in the dynamic link library or the static link library according to the reading method;

[0147] The encrypted bytecode is decrypted using a preset decryption algorithm to obtain a decrypted bytecode.

[0148] According to one or more embodiments of the present disclosure, [Example 5] provides the method of Example 1 or Example 2, wherein calling a pre-created code runner to run the decrypted bytecode includes:

[0149] Get the running function of the code runner to load the dynamic link library or static link library;

[0150] The decrypted bytecode is run through the run function.

[0151] According to one or more embodiments of the present disclosure, [Example 6] provides the method of Example 3, wherein the array declaration expression and the unique identification name of the bytecode corresponding to the original bytecode are processed to generate a corresponding code snippet, including:

[0152] Using the string of the unique identification name of the bytecode corresponding to the original bytecode as the key, and the array created by the array declaration expression as the value;

[0153] The key and the value are combined according to a preset data type to obtain a corresponding code snippet.

[0154] According to one or more embodiments of the present disclosure, [Example 7] provides the method of any one of Examples 1-6, wherein the native code template includes at least the following functions: a function for obtaining an encrypted bytecode; and a function for obtaining a decrypted bytecode.

[0155] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of this disclosure can be achieved, and this document is not limited here.

[0156] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.< / char>

Claims

1. A compiling method, characterized in that: include: Compiling the original source code obtained in advance into corresponding original bytecode; wherein the original source code is an interpreted language; Generate a corresponding dynamic link library or static link library according to the encrypted bytecode corresponding to the original bytecode and a pre-acquired native code template; In response to the running operation of the program, reading and decrypting the encrypted bytecode in the dynamic link library or the static link library to obtain the decrypted bytecode; Calling a pre-created code runner to run the decrypted bytecode; The generating a corresponding dynamic link library or static link library according to the encrypted bytecode corresponding to the original bytecode and the pre-acquired native code template includes: Determine an array declaration expression of a preset element type corresponding to the encrypted bytecode; Processing the array declaration expression and the unique identification name of the bytecode corresponding to the encrypted bytecode to generate a corresponding code snippet; The code snippet is inserted into a pre-acquired native code template, and compiled to obtain a corresponding dynamic link library or static link library.

2. The method according to claim 1, characterized in that: The step of compiling the pre-acquired original source code into the corresponding original bytecode includes: The pre-acquired original source code is compiled by a pre-configured bytecode compiler to obtain corresponding original bytecode; wherein the original source code is the source code corresponding to one or more original source code files.

3. The method according to claim 1, characterized in that The step of reading and decrypting the encrypted bytecode in the dynamic link library or the static link library to obtain the decrypted bytecode comprises: Determine a corresponding reading method according to the location of the encrypted bytecode in the dynamic link library or the static link library; Read the encrypted bytecode in the dynamic link library or the static link library according to the reading method; The encrypted bytecode is decrypted using a preset decryption algorithm to obtain a decrypted bytecode.

4. The method according to claim 1, characterized in that: The calling of a pre-created code runner to run the decrypted bytecode includes: Get the running function of the code runner to load the dynamic link library or static link library; The decrypted bytecode is run through the run function.

5. The method according to claim 1, characterized in that The processing of the array declaration expression and the unique identification name of the bytecode corresponding to the encrypted bytecode to generate a corresponding code snippet includes: Using the string of the unique identification name of the bytecode corresponding to the encrypted bytecode as a key, and the array created by the array declaration expression as a value; The key and the value are combined according to a preset data type to obtain a corresponding code snippet.

6. The method according to any one of claims 1 to 5, characterized in that: The native code template includes at least the following functions: a function for obtaining an encrypted bytecode; and a function for obtaining a decrypted bytecode.

7. A compiling device, characterized in that: include: A compiling module, used to compile the original source code acquired in advance into the corresponding original bytecode; wherein the original source code is an interpreted language; A generation module, used to generate a corresponding dynamic link library or static link library according to the encrypted bytecode corresponding to the original bytecode and a pre-acquired native code template; A decryption module, used for reading and decrypting the encrypted bytecode in the dynamic link library or the static link library in response to the running operation of the program to obtain the decrypted bytecode; A calling and running module is used to call a pre-created code runner to run the decrypted bytecode; The generating module comprises: A determination unit, used to determine an array declaration expression of a preset element type corresponding to the encrypted bytecode; A generating unit, used for processing the array declaration expression and the unique identification name of the bytecode corresponding to the encrypted bytecode to generate a corresponding code snippet; The compiling unit is used to insert the code snippet into a pre-acquired native code template, and compile to obtain a corresponding dynamic link library or static link library.

8. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can perform the compiling method according to any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the compilation method according to any one of claims 1 to 6 when executed.

10. A computer program product, characterized in that The computer program product comprises a computer program, which, when executed by a processor, implements the compilation method according to any one of claims 1 to 6.