Program encryption method and device, electronic equipment and storage medium

By encrypting and replacing the source code with identification, the problem of difficult source code to understand and debug after obfuscation is solved, the confidentiality of the source code is improved, and efficient encryption and decryption management of the source code is realized.

CN119150317AInactive Publication Date: 2024-12-17CHINA THREE GORGES TECH CO LTD +1
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411167622.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-23
Publication Date
2024-12-17
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

After the existing technology obfuscates the source code, the obtained source code is difficult to understand, and the obfuscated source code is difficult to debug, resulting in insufficient confidentiality of the source code.

Method used

By obtaining the current encryption requirements, determining the source code to be encrypted from the preset program source code, and encrypting the source code to be encrypted based on the current encryption requirements, obtaining the encrypted source code and encryption identifier, and replacing the encrypted source code to be encrypted. The source code is used to mark the replacement location with encryption identifier after replacement, to determine whether the user's identity is in the decryption personnel library, and if so, the decryption process will be performed.

Benefits of technology

It improves the confidentiality of the source code, solves the problem of difficult to understand and debug the source code after obfuscation, and ensures the security of the source code.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119150317A_ABST
    Figure CN119150317A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of computers, in particular to a program encryption method and device, electronic equipment and a storage medium. The method comprises the following steps: acquiring a current encryption demand; determining a to-be-encrypted source code from preset program source codes based on the current encryption demand, and encrypting the to-be-encrypted source code based on the current encryption demand to obtain an encrypted source code and an encryption identifier corresponding to the encrypted source code; and replacing the to-be-encrypted source code with the encrypted source code, and marking a replacement position by using an encryption identifier corresponding to the encrypted source code after replacement. Therefore, the problems that in the prior art, source codes obtained after the source codes are confused are difficult to understand, and the confused source codes are difficult to debug are solved, and the confidentiality of the source codes is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a program encryption method, device, electronic device and storage medium. Background Art

[0002] With the rapid development of the IT (Information Technology) industry, the source code of each IT project has become the corporate secret and core of each IT company. Since the executable file of the project is made public when the project is operated, and the executable file is compiled and generated by the source code of the project; and the executable file can be easily cracked by static decompilation tools to obtain the source code of the project, which will cause huge losses to the IT company, so the core source code of the project needs to be encrypted before the IT project is operated.

[0003] In the related technology, a method for encrypting core source code is provided, which can be specifically: when a developer is writing source code, if the developer wants to encrypt a section of core source code, the developer can manually modify the standard function name, method name or class name in the core source code to a custom name, thereby obfuscating the core source code and further encrypting the core source code.

[0004] However, the source code obtained after obfuscating the core source code is difficult to understand, and debugging based on the obfuscated source code is also difficult, which needs to be solved urgently. Summary of the invention

[0005] The present application provides a program encryption method, device, electronic device and storage medium to solve the problem that the source code obtained after obfuscating the source code in the prior art is difficult to understand and the obfuscated source code is difficult to debug, thereby improving the confidentiality of the source code.

[0006] To achieve the above-mentioned purpose, the first embodiment of the present application proposes a program encryption method, comprising the following steps:

[0007] Get the current encryption requirements;

[0008] Based on the current encryption requirement, determining source code to be encrypted from preset program source codes, and encrypting the source code to be encrypted based on the current encryption requirement to obtain an encrypted source code and an encryption identifier corresponding to the encrypted source code;

[0009] The encrypted source code is used to replace the source code to be encrypted, and after the replacement, the replacement position is marked with the encryption identifier corresponding to the encrypted source code.

[0010] According to an embodiment of the present application, determining the source code to be encrypted from the preset program source code based on the current encryption requirement includes:

[0011] Based on the current encryption requirement, determining a position to be encrypted;

[0012] Determining a start encryption position and an end encryption position in the preset program source code according to the position to be encrypted;

[0013] The program source code between the start encryption position and the end encryption position is used as the source code to be encrypted.

[0014] According to an embodiment of the present application, the step of determining the start encryption position and the end encryption position in the preset program source code according to the position to be encrypted includes:

[0015] Determine a start encryption mark and an end encryption mark according to the position to be encrypted;

[0016] The first character position identical to the start encryption mark is determined from the preset program source code as the start encryption position, and the last character position identical to the end encryption mark is determined from the preset program source code as the end encryption position.

[0017] According to an embodiment of the present application, the encrypting the source code to be encrypted based on the current encryption requirement to obtain the encrypted source code and the encryption identifier corresponding to the encrypted source code includes:

[0018] Determine a target encryption strategy according to the current encryption requirement;

[0019] The source code to be encrypted is encrypted according to the target encryption strategy to obtain the encrypted source code, and the encrypted source code is marked based on a preset marking strategy to obtain an encryption identifier corresponding to the encrypted source code.

[0020] According to an embodiment of the present application, after replacing the to-be-encrypted source code with the encrypted source code and marking the replacement position with the encryption identifier corresponding to the encrypted source code after the replacement, the method further includes:

[0021] Determine whether the user's decryption request is received;

[0022] If a decryption request from the user is received, the identity information of the user is obtained, and according to the identity information, it is determined whether the user is in a preset decryption personnel database;

[0023] If the user is in a preset decryption personnel database, the position to be decrypted is determined based on the encryption identifier corresponding to the encrypted source code, and the encrypted source code is decrypted according to the position to be decrypted to obtain the source code to be encrypted.

[0024] According to an embodiment of the present application, after determining whether the user is in a preset decryption personnel database according to the identity information, the method further includes:

[0025] If the user is not in the preset decryption personnel database, a decryption failure message is sent to a preset mobile terminal.

[0026] According to the program encryption method proposed in the embodiment of the present application, based on the current encryption requirements, the source code to be encrypted can be determined from the preset program source code, and the source code to be encrypted can be encrypted based on the current encryption requirements to obtain the encrypted source code and the encryption identifier corresponding to the encrypted source code; the encrypted source code is replaced with the source code to be encrypted, and the replacement position is marked with the encryption identifier corresponding to the encrypted source code after the replacement. Thus, the problem that the source code obtained after the source code is obfuscated in the prior art is difficult to understand and the obfuscated source code is difficult to debug is solved, and the confidentiality of the source code is improved.

[0027] To achieve the above-mentioned purpose, a second embodiment of the present application provides a program encryption device, comprising:

[0028] Acquisition module, used to obtain current encryption requirements;

[0029] A processing module, configured to determine a source code to be encrypted from preset program source codes based on the current encryption requirement, and encrypt the source code to be encrypted based on the current encryption requirement to obtain an encrypted source code and an encryption identifier corresponding to the encrypted source code;

[0030] The replacement module is used to replace the source code to be encrypted with the encrypted source code, and to mark the replacement position with the encryption identifier corresponding to the encrypted source code after the replacement.

[0031] According to one embodiment of the present application, the processing module includes:

[0032] A first determining unit, configured to determine a position to be encrypted based on the current encryption requirement;

[0033] A second determining unit, configured to determine a start encryption position and an end encryption position in the preset program source code according to the position to be encrypted;

[0034] The definition unit is used to use the program source code between the start encryption position and the end encryption position as the source code to be encrypted.

[0035] According to one embodiment of the present application, the definition unit includes:

[0036] A first determining subunit, used to determine a start encryption identifier and an end encryption identifier according to the position to be encrypted;

[0037] The second determination subunit is used to determine the first character position that is the same as the start encryption identifier from the preset program source code as the start encryption position, and to determine the last character position that is the same as the end encryption identifier from the preset program source code as the end encryption position.

[0038] According to one embodiment of the present application, the processing module is specifically used to:

[0039] Determine a target encryption strategy according to the current encryption requirement;

[0040] The source code to be encrypted is encrypted according to the target encryption strategy to obtain the encrypted source code, and the encrypted source code is marked based on a preset marking strategy to obtain an encryption identifier corresponding to the encrypted source code.

[0041] According to an embodiment of the present application, after replacing the to-be-encrypted source code with the encrypted source code and marking the replacement position with the encryption identifier corresponding to the encrypted source code after the replacement, the replacement module further includes:

[0042] A first judging unit, used to judge whether a decryption request of a user is received;

[0043] A second judgment unit is used to obtain the identity information of the user when receiving the decryption demand of the user, and judge whether the user is in a preset decryption personnel database according to the identity information;

[0044] The decryption unit is used to determine the position to be decrypted based on the encryption identifier corresponding to the encrypted source code when the user is in a preset decryption personnel database, and decrypt the encrypted source code according to the position to be decrypted to obtain the source code to be encrypted.

[0045] According to an embodiment of the present application, after determining whether the user is in a preset decryption personnel database according to the identity information, the second determination unit is further configured to:

[0046] When the user is not in the preset decryption personnel database, a decryption failure message is sent to a preset mobile terminal.

[0047] According to the program encryption device proposed in the embodiment of the present application, based on the current encryption requirements, the source code to be encrypted can be determined from the preset program source code, and the source code to be encrypted can be encrypted based on the current encryption requirements to obtain the encrypted source code and the encryption identifier corresponding to the encrypted source code; the encrypted source code is replaced with the source code to be encrypted, and the replacement position is marked with the encryption identifier corresponding to the encrypted source code after the replacement. Thus, the problem that the source code obtained after the source code is obfuscated in the prior art is difficult to understand and the obfuscated source code is difficult to debug is solved, and the confidentiality of the source code is improved.

[0048] To achieve the above objectives, the third aspect of the present application proposes an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the program encryption method as described in the above embodiments.

[0049] To achieve the above objectives, the fourth aspect of the present application proposes a computer-readable storage medium on which a computer program is stored. The program is executed by a processor to implement the program encryption method as described in the above embodiments.

[0050] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:

[0052] Figure 1 A flowchart of a program encryption method provided according to an embodiment of the present application;

[0053] Figure 2 A block diagram of a program encryption device provided according to an embodiment of the present application;

[0054] Figure 3 It is a schematic diagram of the structure of an electronic device provided according to an embodiment of the present application. DETAILED DESCRIPTION

[0055] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.

[0056] The following describes a program encryption method, device, electronic device, and storage medium according to an embodiment of the present application with reference to the accompanying drawings. First, the program encryption method according to an embodiment of the present application will be described with reference to the accompanying drawings.

[0057] Figure 1 It is a flowchart of a program encryption method according to an embodiment of the present application.

[0058] like Figure 1 As shown, the program encryption method includes the following steps:

[0059] In step S101, the current encryption requirement is obtained.

[0060] The current encryption requirement specifies which source code parts need to be encrypted and which encryption algorithm and key to use. The current encryption requirement can be obtained through a configuration file, command line parameters, or a dedicated interface.

[0061] In step S102, based on the current encryption requirement, source code to be encrypted is determined from preset program source codes, and the source code to be encrypted is encrypted based on the current encryption requirement to obtain the encrypted source code and the encryption identifier corresponding to the encrypted source code.

[0062] That is to say, according to the current encryption requirements, a parser (such as an existing parsing library (ANTLR (Another Tool for Language Recognition, an open source syntax analyzer), etc.)) or a script can be used to read the preset program source code, and by searching for specific functions, classes, string constants, etc., the part of the preset program source code that needs to be encrypted, that is, the source code to be encrypted, is identified. For the determined source code to be encrypted, the selected encryption algorithm can be used to encrypt it, thereby generating an encrypted source code and an encryption identifier corresponding to the encrypted source code.

[0063] For ease of understanding, the following describes in detail how to determine the source code to be encrypted from the preset program source code based on the current encryption requirement.

[0064] As a possible implementation method, in some embodiments, based on the current encryption requirements, the source code to be encrypted is determined from the preset program source code, including: based on the current encryption requirements, determining the position to be encrypted; determining the starting encryption position and the ending encryption position in the preset program source code according to the position to be encrypted; and using the program source code between the starting encryption position and the ending encryption position as the source code to be encrypted.

[0065] Specifically, the position to be encrypted is located according to the current encryption requirements, and then the starting encryption position and the ending encryption position in the preset program source code can be determined according to the position to be encrypted, wherein the starting encryption position is usually the starting position of a specific identifier or pattern, and the ending encryption position can be determined depending on the specific encryption scope and context. It should be noted that for simple string constant encryption, the starting encryption position and the ending encryption position may be the quotation marks of the string. For more complex structures (such as function bodies), it may be necessary to parse the code structure to determine the starting encryption position and the ending encryption position. After determining the starting encryption position and the ending encryption position, the program source code between the starting encryption position and the ending encryption position can be extracted from the preset program source code as the source code to be encrypted.

[0066] After the source code to be encrypted is obtained, the extracted source code fragment to be encrypted can be verified through output or log recording to ensure the accuracy of the source code to be encrypted.

[0067] Further, in some embodiments, the starting encryption position and the ending encryption position in the preset program source code are determined according to the position to be encrypted, including: determining the starting encryption identifier and the ending encryption identifier according to the position to be encrypted; determining the first character position identical to the starting encryption identifier from the preset program source code as the starting encryption position, and determining the last character position identical to the ending encryption identifier from the preset program source code as the ending encryption position.

[0068] Among them, the starting encryption identifier is a specific string or symbol used to mark the starting position of the code segment to be encrypted, and the ending encryption identifier is a specific string or symbol used to mark the ending position of the code segment to be encrypted. These identifiers can be uniquely and clearly identified in the preset program source code and can be pre-set by the user.

[0069] Specifically, by traversing the preset program source code, searching for a character sequence that is exactly the same as the starting encryption identifier, recording the first character position that is exactly the same as the starting encryption identifier as the starting encryption position, and searching for the last character position that is exactly the same as the ending encryption identifier after the starting encryption position as the ending encryption position, ensuring that this position marks the end of the source code segment to be encrypted.

[0070] For ease of understanding, the following describes in detail how to encrypt the source code to be encrypted based on the current encryption requirements to obtain the encrypted source code and the encryption identifier corresponding to the encrypted source code.

[0071] As a possible implementation method, in some embodiments, encrypting the source code to be encrypted based on the current encryption requirement to obtain the encrypted source code and the encryption identifier corresponding to the encrypted source code includes: determining a target encryption strategy according to the current encryption requirement; encrypting the source code to be encrypted according to the target encryption strategy to obtain the encrypted source code, and marking the encrypted source code based on a preset marking strategy to obtain the encryption identifier corresponding to the encrypted source code.

[0072] Specifically, according to the current encryption needs, an appropriate target encryption strategy is analyzed and determined, including encryption algorithms (such as AES (Advanced Encryption Standard)), encryption modes (such as ECB (Electronic Code Book)), and key management strategies, the source code to be encrypted is read from the preset program source code, the source code to be encrypted is encrypted using the selected target encryption strategy, the source code to be encrypted is converted into a byte stream or a text stream, and the encrypted code is encrypted using the selected encryption algorithm. During the encryption process, a key is required to encrypt the source code to be encrypted. After the encryption process is completed, the encrypted data is converted into a source code format to generate an encrypted source code (a format that is unreadable or difficult to directly understand), and the encryption identifier corresponding to the encrypted source code is determined according to the preset marking strategy. The encryption identifier is used to mark the encrypted source code segment.

[0073] In step S103, the encrypted source code replaces the source code to be encrypted, and after the replacement, the replacement position is marked with the encryption identifier corresponding to the encrypted source code.

[0074] That is, in the preset source code, the source code to be encrypted is replaced with the encrypted source code, and an encryption mark corresponding to the encrypted source code is added at the replaced position to mark that the position has been encrypted, such as by adding comments, modifying the code style or using specific metadata tags.

[0075] Furthermore, in some embodiments, after replacing the source code to be encrypted with the encrypted source code and marking the replacement position with the encryption identifier corresponding to the encrypted source code after the replacement, it also includes: judging whether a decryption request from the user is received; if a decryption request from the user is received, obtaining the identity information of the user, and judging whether the user is in a preset decryption personnel library according to the identity information; if the user is in the preset decryption personnel library, determining the position to be decrypted based on the encryption identifier corresponding to the encrypted source code, and decrypting the encrypted source code according to the position to be decrypted to obtain the source code to be encrypted.

[0076] Specifically, after encrypting the source code to be encrypted in the preset program source code, the system can continuously monitor whether there is a user's decryption demand through a user interface, an API (Application Programming Interface) call, etc. Once the user's decryption demand is received, the validity of the demand needs to be determined. If the decryption demand is valid, the user identity information (including user name, password, access token, etc.) requesting decryption can be obtained, and the user's identity information can be compared with the preset decryption personnel library to confirm whether the user has the right to perform the decryption operation. If the user identity information exists in the preset decryption personnel library, the system determines that the user has the right to decrypt, and then finds the encryption identifier corresponding to the encrypted source code by searching for a specific mark or identifier to determine the position to be decrypted. According to the encryption position, its starting encryption position and the ending encryption position can be determined, so as to locate the encrypted source code, retrieve the key and encryption algorithm information associated with the position from the preset encryption personnel library, and use this information to decrypt the encrypted source code, and restore the encrypted source code to the original source code to be encrypted. After decryption is completed, the decrypted source code to be encrypted can be replaced back to the corresponding position in the preset program source code.

[0077] Optionally, in some embodiments, after determining whether the user is in a preset decryption personnel database based on the identity information, the method further includes: if the user is not in the preset decryption personnel database, sending a decryption failure message to a preset mobile terminal.

[0078] It is understandable that if the user is not in the preset decryption personnel database, the system will reject the decryption request, indicating that the user does not have decryption authority, and generate corresponding decryption failure information (including error code and description so that the user can understand the reason for the failure to decrypt), and send the decryption failure information to the preset mobile terminal (such as mobile phone, tablet computer, etc.) associated with the user in an appropriate manner (such as SMS, push notification, email, etc.). After receiving the decryption failure information, the user can understand the reason according to the failure information and take appropriate actions, such as contacting the administrator, checking his own authority, etc.

[0079] According to the program encryption method proposed in the embodiment of the present application, based on the current encryption requirements, the source code to be encrypted can be determined from the preset program source code, and the source code to be encrypted can be encrypted based on the current encryption requirements to obtain the encrypted source code and the encryption identifier corresponding to the encrypted source code; the encrypted source code is replaced with the source code to be encrypted, and the replacement position is marked with the encryption identifier corresponding to the encrypted source code after the replacement. Thus, the problem that the source code obtained after the source code is obfuscated in the prior art is difficult to understand and the obfuscated source code is difficult to debug is solved, and the confidentiality of the source code is improved.

[0080] Next, the program encryption device proposed according to the embodiment of the present application is described with reference to the accompanying drawings.

[0081] Figure 2 It is a block diagram of a program encryption device according to an embodiment of the present application.

[0082] like Figure 2 As shown, the program encryption device 10 includes: an acquisition module 100 , a processing module 200 and a replacement module 300 .

[0083] Wherein, the acquisition module 100 is used to obtain the current encryption requirement;

[0084] The processing module 200 is used to determine the source code to be encrypted from the preset program source code based on the current encryption requirement, and encrypt the source code to be encrypted based on the current encryption requirement to obtain the encrypted source code and the encryption identifier corresponding to the encrypted source code;

[0085] The replacement module 300 is used to replace the source code to be encrypted with the encrypted source code, and to mark the replacement position with the encryption identifier corresponding to the encrypted source code after the replacement.

[0086] Furthermore, in some embodiments, the processing module 200 includes:

[0087] A first determining unit, configured to determine a position to be encrypted based on a current encryption requirement;

[0088] A second determining unit, used to determine a start encryption position and an end encryption position in a preset program source code according to the position to be encrypted;

[0089] The definition unit is used to use the program source code between the start encryption position and the end encryption position as the source code to be encrypted.

[0090] Furthermore, in some embodiments, the definition unit includes:

[0091] A first determining subunit, used to determine a start encryption identifier and an end encryption identifier according to a position to be encrypted;

[0092] The second determination subunit is used to determine the first character position identical to the start encryption mark from the preset program source code as the start encryption position, and determine the last character position identical to the end encryption mark from the preset program source code as the end encryption position.

[0093] Furthermore, in some embodiments, the processing module 200 is specifically configured to:

[0094] Determine the target encryption strategy based on current encryption requirements;

[0095] The source code to be encrypted is encrypted according to the target encryption strategy to obtain the encrypted source code, and the encrypted source code is marked based on a preset marking strategy to obtain an encryption identifier corresponding to the encrypted source code.

[0096] Furthermore, in some embodiments, after replacing the to-be-encrypted source code with the encrypted source code and marking the replacement position with the encryption identifier corresponding to the encrypted source code after the replacement, the replacement module 300 further includes:

[0097] A first judging unit, used to judge whether a decryption request of a user is received;

[0098] The second judgment unit is used to obtain the user's identity information when receiving the user's decryption demand, and judge whether the user is in the preset decryption personnel database according to the identity information;

[0099] The decryption unit is used to determine the position to be decrypted based on the encryption identifier corresponding to the encrypted source code when the user is in the preset decryption personnel database, and decrypt the encrypted source code according to the position to be decrypted to obtain the source code to be encrypted.

[0100] Furthermore, in some embodiments, after determining whether the user is in a preset decryption personnel database according to the identity information, the second determination unit is further configured to:

[0101] When the user is not in the preset decryption personnel database, a decryption failure message is sent to the preset mobile terminal.

[0102] It should be noted that the aforementioned explanation of the program encryption method embodiment is also applicable to the program encryption device of this embodiment, and will not be repeated here.

[0103] According to the program encryption device proposed in the embodiment of the present application, based on the current encryption requirements, the source code to be encrypted can be determined from the preset program source code, and the source code to be encrypted can be encrypted based on the current encryption requirements to obtain the encrypted source code and the encryption identifier corresponding to the encrypted source code; the encrypted source code is replaced with the source code to be encrypted, and the replacement position is marked with the encryption identifier corresponding to the encrypted source code after the replacement. Thus, the problem that the source code obtained after the source code is obfuscated in the prior art is difficult to understand and the obfuscated source code is difficult to debug is solved, and the confidentiality of the source code is improved.

[0104] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device may include:

[0105] A memory 301 , a processor 302 , and a computer program stored in the memory 301 and executable on the processor 302 .

[0106] When the processor 302 executes the program, the program encryption method provided in the above embodiment is implemented.

[0107] Furthermore, the electronic device further comprises:

[0108] The communication interface 303 is used for communication between the memory 301 and the processor 302 .

[0109] The memory 301 is used to store computer programs that can be run on the processor 302 .

[0110] The memory 301 may include a high-speed RAM (Random Access Memory) memory, and may also include a non-volatile memory, such as at least one disk memory.

[0111] If the memory 301, the processor 302 and the communication interface 303 are implemented independently, the communication interface 303, the memory 301 and the processor 302 can be connected to each other through a bus and communicate with each other. The bus can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0112] Optionally, in a specific implementation, if the memory 301, the processor 302 and the communication interface 303 are integrated on a chip, the memory 301, the processor 302 and the communication interface 303 can communicate with each other through an internal interface.

[0113] The processor 302 may be a CPU (Central Processing Unit), or an ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement the embodiments of the present application.

[0114] An embodiment of the present application also provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the above program encryption method is implemented.

[0115] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.

[0116] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms are not necessarily directed to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.

[0117] Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limitations on the present application. Ordinary technicians in this field can change, modify, replace and modify the above embodiments within the scope of the present application.

Claims

1. A program encryption method, characterized in that: The following steps are involved: Get the current encryption requirements; Based on the current encryption requirement, determining source code to be encrypted from preset program source codes, and encrypting the source code to be encrypted based on the current encryption requirement to obtain an encrypted source code and an encryption identifier corresponding to the encrypted source code; The encrypted source code is used to replace the source code to be encrypted, and after the replacement, the replacement position is marked with the encryption identifier corresponding to the encrypted source code.

2. The method according to claim 1, characterized in that The step of determining the source code to be encrypted from the preset program source code based on the current encryption requirement includes: Based on the current encryption requirement, determining a position to be encrypted; Determining a start encryption position and an end encryption position in the preset program source code according to the position to be encrypted; The program source code between the start encryption position and the end encryption position is used as the source code to be encrypted.

3. The method according to claim 2, characterized in that The step of determining the start encryption position and the end encryption position in the preset program source code according to the position to be encrypted includes: Determine a start encryption mark and an end encryption mark according to the position to be encrypted; The first character position identical to the start encryption mark is determined from the preset program source code as the start encryption position, and the last character position identical to the end encryption mark is determined from the preset program source code as the end encryption position.

4. The method according to claim 1, characterized in that: The encrypting the source code to be encrypted based on the current encryption requirement to obtain the encrypted source code and an encryption identifier corresponding to the encrypted source code includes: Determine a target encryption strategy according to the current encryption requirement; The source code to be encrypted is encrypted according to the target encryption strategy to obtain the encrypted source code, and the encrypted source code is marked based on a preset marking strategy to obtain an encryption identifier corresponding to the encrypted source code.

5. The method according to claim 1, characterized in that After replacing the to-be-encrypted source code with the encrypted source code and marking the replacement position with the encryption identifier corresponding to the encrypted source code after the replacement, the method further includes: Determine whether the user's decryption request is received; If a decryption request from the user is received, the identity information of the user is obtained, and according to the identity information, it is determined whether the user is in a preset decryption personnel database; If the user is in the preset decryption personnel database, the position to be decrypted is determined based on the encryption identifier corresponding to the encrypted source code, and the encrypted source code is decrypted according to the position to be decrypted to obtain the source code to be encrypted.

6. The method according to claim 5, characterized in that After determining whether the user is in a preset decryption personnel database according to the identity information, the method further includes: If the user is not in the preset decryption personnel database, a decryption failure message is sent to a preset mobile terminal.

7. A program encryption device, characterized in that: include: Acquisition module, used to obtain current encryption requirements; A processing module, configured to determine a source code to be encrypted from preset program source codes based on the current encryption requirement, and encrypt the source code to be encrypted based on the current encryption requirement to obtain an encrypted source code and an encryption identifier corresponding to the encrypted source code; The replacement module is used to replace the source code to be encrypted with the encrypted source code, and to mark the replacement position with the encryption identifier corresponding to the encrypted source code after the replacement.

8. The device according to claim 7, characterized in that The processing module comprises: A first determining unit, configured to determine a position to be encrypted based on the current encryption requirement; A second determining unit, configured to determine a start encryption position and an end encryption position in the preset program source code according to the position to be encrypted; The definition unit is used to use the program source code between the start encryption position and the end encryption position as the source code to be encrypted.

9. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the program encryption method according to any one of claims 1 to 6.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: The program is executed by a processor to implement the program encryption method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • File filter protecting method, drive device and client end

    CN102314579A

  • File protection method and device, computer device and storage medium

    CN109218295A

  • Text encryption method and device

    CN112632588A

  • Code encryption and decryption method and related device

    CN118094493A

  • Selective Data Encryption and Decryption Method and Apparatus

    US20120134490A1