Anti-decompilation encryption and decryption method, device, equipment and storage medium

CN115310057BActive Publication Date: 2026-08-28QI AN XIN TECHNOLOGY GROUP INC +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210827744.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-13
Publication Date
2026-08-28
Estimated Expiration
2042-07-13

AI Technical Summary

Technical Problem

[0004]本发明实施例提供一种防反编译的加密、解密方法、装置、设备和存储介质,以解决防止Class文件被反编译时导致的影响代码的执行效率的技术问题

Benefits of technology

[0058] The encryption and decryption method, apparatus, device, and storage medium for anti-decompilation provided in this invention encrypt the target code file and distribute the decryption program code to the decryption peripheral based on decryption auxiliary information. The decryption program is used to decrypt the encrypted target code file. The target code file and the decryption program are not easily decompiled. Moreover, the decryption auxiliary information is obtained based on at least one of the public key and the user authorization code and the clock information of the decryption peripheral included in the target information, which provides high security. Furthermore, since the processing logic of the code is not modified, the execution efficiency is not affected after decryption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115310057B_ABST
    Figure CN115310057B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide an anti-decompilation encryption and decryption method, device, equipment and storage medium. The encryption method comprises: encrypting a target code file by using an obtained private key to obtain an encrypted target code file; obtaining decryption auxiliary information according to a public key corresponding to the private key and target information; the target information comprises at least one of a user authorization code and clock information of a decryption peripheral; dispersing code of a decryption program into the decryption peripheral according to the decryption auxiliary information; and the decryption program is used for decrypting the encrypted target code file. In the above scheme, the encrypted target code file is not easy to be decompiled, and the execution efficiency is not affected after decryption because the processing logic of the code is not changed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to an encryption and decryption method, apparatus, device, and storage medium that prevents reverse engineering. Background Technology

[0002] According to the Java Virtual Machine Specification, Class files compiled from Java are stored using a pseudo-structure similar to C language structs, making them very easy to decompile through reverse engineering.

[0003] Existing technologies commonly employ code obfuscation to prevent Class files from being decompiled. However, this effectively alters the code's execution logic, impacting runtime efficiency and potentially causing logical errors, thus increasing the difficulty of troubleshooting. Summary of the Invention

[0004] This invention provides an encryption and decryption method, apparatus, device, and storage medium to prevent decompilation, thereby solving the technical problem of preventing Class files from being decompiled and affecting code execution efficiency.

[0005] Specifically, the embodiments of the present invention provide the following technical solutions:

[0006] In a first aspect, embodiments of the present invention provide an encryption method for preventing decompilation, comprising:

[0007] The obtained private key is used to encrypt the target code file, resulting in the encrypted target code file;

[0008] Based on the public key corresponding to the private key and the target information, decryption assistance information is obtained; the target information includes at least one of the following: user authorization code and clock information of the decryption peripheral.

[0009] Based on the decryption assistance information, the code of the decryption program is distributed and stored in the decryption peripheral; the decryption program is used to decrypt the encrypted target code file.

[0010] Optionally, the decryption assistance information includes: code block splitting information and storage location information. The step of distributing and storing the decryption program code in the decryption peripheral device according to the decryption assistance information includes:

[0011] Based on the code block splitting information, the decryption program's code is split into multiple code blocks according to preset rules;

[0012] Based on the storage location information, the code blocks are distributed and stored in the decryption peripheral in a target order; the target order is an order other than the original order of the multiple code blocks in the decryption program.

[0013] Optionally, the decryption assistance information is bytecode; the storage location information in the bytecode includes at least one of the following: the starting position of the starting code block, the starting position of the ending code block, and the starting position of each code block.

[0014] Optionally, before encrypting the target code file using the obtained private key, the following steps are also included:

[0015] Based on the identification information of the target code file, determine whether the target code file needs to be encrypted;

[0016] If the target code file needs to be encrypted, then the step of encrypting the target code file using the obtained private key is performed.

[0017] Optionally, the identification information of the target code file includes a magic number; or,

[0018] The identification information of the target code file includes a magic number and at least one of the following: version number, file package name, class name, and descriptor;

[0019] The magic number is used to indicate the type of the target code file.

[0020] Optionally, after encrypting the target code file using the obtained private key, the method further includes:

[0021] Write the encryption identifier to a preset location in the encrypted target code file.

[0022] Optionally, the method further includes:

[0023] Obtain user equipment information and user identification information. The user equipment information includes at least one of the following: CPU information, operating system information, and network card information.

[0024] Based on the user equipment information and user identification information, the private key and the private key corresponding to the private key are obtained using the target encryption algorithm;

[0025] Split the public key into a first part and a second part;

[0026] The first part is used as the authorization certificate, and the second part is stored separately in the decryption peripheral.

[0027] Optionally, decryption assistance information is obtained based on the public key corresponding to the private key and the target information, including:

[0028] Decryption assistance information is obtained based on the authorization certificate and target information.

[0029] Optionally, a randomly generated string can be used as the user authorization code.

[0030] Secondly, embodiments of the present invention provide a decryption method to prevent reverse engineering, including:

[0031] Obtain the target code file encrypted with the private key and decryption assistance information; the decryption assistance information is obtained based on the public key corresponding to the private key and the target information, and the target information includes at least one of the following: user authorization code and clock information of the decryption peripheral;

[0032] Based on the decryption assistance information, the code of the decryption program stored in the decryption peripheral is restored to obtain the decryption program.

[0033] The encrypted target code file is decrypted using the decryption program and public key.

[0034] Optionally, the decryption assistance information includes: code block splitting information and storage location information. Based on the decryption assistance information, the code of the decryption program stored in the decryption peripheral is restored to obtain the decryption program, including:

[0035] Based on the storage location information, multiple code blocks stored scattered in the decryption peripheral are obtained in a target order; the target order is an order other than the original order of the multiple code blocks in the decryption program.

[0036] Based on the splitting information of the code blocks and the multiple code blocks, the decryption program is restored according to preset rules.

[0037] Optionally, the method further includes:

[0038] Obtain the user authorization code and authorization certificate; the authorization certificate is the first part of the public key.

[0039] The decryption assistance information is obtained based on the authorization certificate and the target information;

[0040] The second part of the public key is stored in a distributed manner in the decryption peripheral. The decryption program and the public key are used to decrypt the encrypted target code file, including:

[0041] Obtain the second part of the public key that is stored in a distributed manner in the decryption peripheral;

[0042] The encrypted target code file is decrypted using the decryption program, the authorization certificate, and the second part of the public key.

[0043] Optionally, before obtaining the decryption assistance information stored in the decryption peripheral, the method further includes:

[0044] Receives a verification code input by the user; the verification code is generated by the decryption peripheral based on the identifier code of the decryption peripheral and a timestamp;

[0045] In response to the user input, the step of obtaining decryption assistance information stored in the decryption peripheral is triggered.

[0046] Optionally, the decryption assistance information is bytecode; the storage location information in the bytecode includes at least one of the following: the starting position of the starting code block, the starting position of the ending code block, and the starting position of each code block.

[0047] Thirdly, embodiments of the present invention provide an anti-decompilation encryption device, comprising:

[0048] The encryption module is used to encrypt the target code file using the obtained private key, resulting in an encrypted target code file.

[0049] The processing module is used to obtain decryption assistance information based on the public key corresponding to the private key and the target information; the target information includes at least one of the following: user authorization code and clock information of the decryption peripheral.

[0050] The processing module is further configured to distribute and store the code of the decryption program in the decryption peripheral device according to the decryption assistance information; the decryption program is used to decrypt the encrypted target code file.

[0051] Fourthly, embodiments of the present invention provide a decryption device to prevent reverse engineering, comprising:

[0052] The acquisition module is used to acquire the target code file obtained by encrypting it with a private key and decryption assistance information; the decryption assistance information is obtained based on the public key corresponding to the private key and the target information, and the target information includes at least one of the following: user authorization code and clock information of the decryption peripheral;

[0053] The processing module is used to restore the code of the decryption program that is stored in the decryption peripheral according to the decryption auxiliary information, so as to obtain the decryption program;

[0054] The decryption module is used to decrypt the encrypted target code file using the decryption program and the public key.

[0055] Fifthly, embodiments of the present invention also provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, it implements the steps of the anti-decompilation encryption method as described in the first aspect or the steps of the anti-decompilation decryption method as described in the second aspect.

[0056] In a sixth aspect, embodiments of the present invention also provide a non-transitory computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, it implements the steps of the anti-decompilation encryption method as described in the first aspect or the steps of the anti-decompilation decryption method as described in the second aspect.

[0057] In a seventh aspect, embodiments of the present invention also provide a computer program product, including a computer program, wherein when the computer program is executed by a processor, it implements the steps of the anti-decompilation encryption method as described in the first aspect or the steps of the anti-decompilation decryption method as described in the second aspect.

[0058] The encryption and decryption method, apparatus, device, and storage medium for anti-decompilation provided in this invention encrypt the target code file and distribute the decryption program code to the decryption peripheral based on decryption auxiliary information. The decryption program is used to decrypt the encrypted target code file. The target code file and the decryption program are not easily decompiled. Moreover, the decryption auxiliary information is obtained based on at least one of the public key and the user authorization code and the clock information of the decryption peripheral included in the target information, which provides high security. Furthermore, since the processing logic of the code is not modified, the execution efficiency is not affected after decryption. Attached Figure Description

[0059] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0060] Figure 1 This is one of the flowcharts illustrating the anti-decompilation encryption method provided in this embodiment of the invention;

[0061] Figure 2 This is an implementation framework diagram of the anti-decompilation encryption method provided in the embodiments of the present invention;

[0062] Figure 3 This is the second flowchart illustrating the decryption method for preventing reverse engineering provided in this embodiment of the invention;

[0063] Figure 4 This is an implementation framework diagram of the anti-decompilation decryption method provided in the embodiments of the present invention;

[0064] Figure 5 This is a schematic diagram of the anti-reverse engineering encryption device provided by the present invention;

[0065] Figure 6 This is a schematic diagram of the anti-reverse engineering decryption device provided by the present invention;

[0066] Figure 7 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation

[0067] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0068] The method in this embodiment of the invention is applied to anti-decompilation scenarios for target code files, such as Java code files.

[0069] In order to prevent decompilation, this invention employs a scheme of encrypting the code file and distributing the decryption program. The target code file and the decryption program are not easily decompiled, and since the processing logic of the code is not modified, the execution efficiency is not affected after decryption.

[0070] The following is combined Figures 1-4 The technical solutions of the embodiments of the present invention will be described in detail with reference to specific examples. The following specific examples can be combined with each other, and the same or similar concepts or processes may not be described again in some examples.

[0071] Figure 1 This is one of the flowcharts illustrating the anti-decompilation encryption method provided in this embodiment of the invention. For example... Figure 1 As shown, the method provided in this embodiment includes:

[0072] Step 101: Use the obtained private key to encrypt the target code file to obtain the encrypted target code file;

[0073] Specifically, a private key and its corresponding public key can be pre-generated. This can be based on the decryptor's user identification information and user device information, or alternatively, it can be obtained using an encryption algorithm based on the decryptor's user identification information and user device information. The user identification information can uniquely identify the decryptor.

[0074] The obtained private key is used to encrypt the target code file. The encryption algorithm can be a preset algorithm, such as RSA256, RSA512, RSA1024, etc. For example, encrypting the target code file using the obtained private key can include: encrypting the target code file using the private key and at least one of the following: version number, file package name, class name, and descriptor. For example, adding at least one of the following encryption information (version number, file package name, class name, descriptor, etc.) to the encrypted target code file can improve security.

[0075] The private key can be determined by the encryptor and communicated to the decryptor.

[0076] Step 102: Obtain decryption assistance information based on the public key corresponding to the private key and the target information; the target information includes at least one of the following: user authorization code and clock information of the decryption peripheral;

[0077] Specifically, the user authorization code can be obtained by the encrypting party and then notified to the decrypting party. Alternatively, a randomly generated string can be used as the user authorization code, for example, a string generated using a random string generation algorithm.

[0078] Each decryption peripheral has built-in clock information, including start time, timing interval, and interval step size. For example, the start time might be 1999-09-09 12:12:12. The timing interval can be represented by the time refresh rate, and the interval step size represents the refresh step size, such as increasing by one second with each refresh. Different decryption peripherals can have different start times, timing intervals, and interval step sizes, adding another unique and seemingly dynamic variable to each decryption peripheral.

[0079] The public key can be determined by the encryptor and form a key pair with the private key in step 101. For example, it can be obtained based on the user information and user device information of the decryptor. Optionally, it can be obtained using the RSA algorithm.

[0080] Based on the public key and at least one of the target information, including the user authorization code and the clock information of the decryption peripheral, decryption auxiliary information is obtained. The decryption auxiliary information can be used as input parameters for distributed storage and decryption program restoration, thereby improving the security against reverse engineering.

[0081] Step 103: Based on the decryption assistance information, distribute the decryption program code to the decryption peripheral device; the decryption program is used to decrypt the encrypted target code file.

[0082] Specifically, the decryption program's code can be broken down, for example, into blocks and stored separately in the decryption peripheral. The specific methods of block breaking and storage can be preset, such as the number of code blocks, the size of the code blocks, the splitting position of the code blocks, the location of the scattered storage, and the order of the scattered storage. Distributing the decryption program's code makes it more difficult to decompile, thereby improving security.

[0083] For example, the entry point of the decryption program might be at a low address within the entire program. Breaking it down might result in a relatively intermediate address, hiding the program's starting address and making it harder to decompile.

[0084] The method in this embodiment encrypts the target code file and stores the decryption program code in a distributed manner on the decryption peripheral based on decryption auxiliary information. The decryption program is used to decrypt the encrypted target code file. The target code file and the decryption program are not easy to decompile. Moreover, the decryption auxiliary information is obtained based on at least one of the public key and the target information, including the user authorization code and the clock information of the decryption peripheral. The security is high. Furthermore, since the processing logic of the code is not modified, the execution efficiency is not affected after decryption.

[0085] In one embodiment, the decryption auxiliary information includes: code block splitting information and storage location information, and step 103 can be implemented in the following way:

[0086] Based on the code block splitting information, the decryption program's code is split into multiple code blocks according to preset rules;

[0087] Based on the storage location information, the code blocks are distributed and stored in the decryption peripheral in the target order; the target order is the order other than the original order of multiple code blocks in the decryption program.

[0088] Specifically, for example, the process of distributing and storing the decryption program using preset rules and a target order can be used to generate a processing program. Decryption auxiliary information can be used as input parameters to trigger this program, which will then split the decryption program's code into multiple code blocks and distribute these blocks to the decryption peripheral according to the target order. This processing program can determine how the decryption program's code is divided into blocks, the number of blocks, their size, etc., for example, based on the code block splitting information. Additionally, it can assign different storage locations to the shuffled code blocks based on storage location information.

[0089] The target order is the order after the original order is shuffled. That is, instead of following the original order of multiple code blocks in the decryption program, they are randomly distributed and stored in the decryption peripheral to reduce the probability of decompilation.

[0090] During decryption, multiple code blocks stored in a scattered manner can be obtained based on the storage location information and the target order. Then, the decryption program can be obtained by reconstructing the decryption program based on the split information and multiple code blocks.

[0091] Optionally, the decryption assistance information is bytecode obtained based on the public key and the target information; the bytecode includes code block splitting information and storage location information, the storage location information including at least one of the following: the starting position of the starting code block, the starting position of the ending code block, and the starting position of each code block.

[0092] For example, the authorization code and certificate issued to the user are converted into bytecode. A portion of the bytecode is used as the basis for decryption, i.e., information about the code block breakdown, such as the number and size of the blocks. Other information is used as storage location information, such as the starting position of each block after decryption, or the starting position of the first or last code block.

[0093] In one embodiment, such as Figure 2 As shown, the procedure before step 101 also includes:

[0094] Based on the identification information of the target code file, determine whether the target code file needs to be encrypted;

[0095] If the target code file needs to be encrypted, then the step of encrypting the target code file using the pre-obtained private key is executed.

[0096] Optionally, the identification information of the target code file includes the magic number; or,

[0097] The identification information of the target code file includes a magic number and at least one of the following: version number, file package name, class name, and descriptor.

[0098] Specifically, the type of the target code file can be determined based on its identification information. Some types of code files may not require encryption, while others do. For example, class files contain important content of a Java program and need to be encrypted to prevent decompilation. For instance, the magic number in a class file is 0xCAFEBABE. The system checks whether the target code file begins with 0xCAFEBABE; if so, it indicates that it is a class file.

[0099] Alternatively, the encryption process can be implemented using a Maven plugin. Maven plugins are very easy to integrate into Java projects and offer good compatibility.

[0100] Optionally, after encrypting the target code file using the pre-obtained private key, the process further includes:

[0101] Write the encryption identifier to a preset location in the encrypted target code file.

[0102] Specifically, an encryption identifier (information declaring that the file is specifically encrypted) is written to a specific preset location in the encrypted file.

[0103] For example, if a user identifies an encryption identifier at a preset location, it indicates that the target code file is encrypted and needs to be decrypted before use. For instance, different encryption users can add encryption identifiers at different locations. Adding an encryption identifier at preset location 1 indicates that encryption was performed by encryption user 1, using public key 1 and private key 1 respectively, and encryption algorithm 1. Adding an encryption identifier at preset location 2 indicates that encryption was performed by encryption user 2, using public key 2 and private key 2 respectively, and encryption algorithm 2.

[0104] In the above embodiments, by adding an encryption identifier at a preset location, the decryptor can more easily identify that the file is encrypted, thus preventing misjudgment.

[0105] Optionally, user equipment information and user identification information are obtained, wherein the user equipment information includes at least one of the following: CPU information, operating system information, and network card information;

[0106] Based on user device information and user identification information, a private key and the corresponding public key are obtained using a target encryption algorithm;

[0107] Split the public key into a first part and a second part;

[0108] The first part is used as the authorization certificate, and the second part is stored separately in the decryption peripheral.

[0109] Specifically, based on user device information and user identification information, the public and private keys are obtained, for example, based on the decryptor's user device information and user identification information, using an encryption algorithm (such as RSA).

[0110] For example, information collection programs can be used to collect information such as the CPU serial number, model, operating system information, or network card information of the user equipment of the party attempting to uncover the information.

[0111] User identification information can be a unique identifier for the decryption party, such as a user's name, department, or contact information.

[0112] To improve security, the public key can be split into a first part and a second part. The first part is sent as an authorization certificate to the decryptor's user device. For example, the authorization certificate is imported for verification when the decryptor uses the decryption peripheral for the first time. The second part is distributed and stored in the decryption peripheral. That is, the second part of the public key is split into information blocks of the same or different sizes and distributed in the decryption peripheral in a certain arrangement, which can reduce the probability of decompilation.

[0113] Alternatively, the decryption assistance information can be obtained from the first part of the public key and the target information.

[0114] In the above implementation, splitting the public key into a first part and a second part can reduce the amount of public key content sent to the decryption party, thereby reducing security risks. The second part is stored in a distributed manner on the decryption peripheral, which provides higher security.

[0115] Figure 3 This is one of the flowcharts illustrating the decryption method for preventing reverse engineering provided in this embodiment of the invention. For example... Figure 3 As shown, the method provided in this embodiment includes:

[0116] Step 201: Obtain the target code file encrypted with the private key and the decryption assistance information; the decryption assistance information is obtained based on the public key corresponding to the private key and the target information, and the target information includes at least one of the following: user authorization code and clock information of the decryption peripheral;

[0117] Step 202: Based on the decryption auxiliary information, restore the code of the decryption program that is stored in the decryption peripheral to obtain the decryption program;

[0118] Step 203: Decrypt the encrypted target code file using the decryption program and public key.

[0119] Specifically, the restoration and decryption processes can be the inverse of the encryption process and the distributed storage process.

[0120] like Figure 4 As shown, the decryption method can be implemented through a decryption identification program, which can identify the encrypted target code file, obtain the decryption program, and call the decryption program to decrypt it. Optionally, the decrypted target code file can also be loaded into memory for execution.

[0121] The decryption and identification program can be implemented using, for example, JVMTI (JVM Tool Interface). When the JVM agent loads the target code file, a corresponding interception function is added. This function identifies the target code file. If an encrypted file is detected, the file's byte stream content is passed to the decryption program for processing. After processing, the decryption program returns the decrypted byte stream to the interception function. The interception function then loads the decrypted byte content into memory.

[0122] Optionally, decryption assistance information can be stored in the decryption peripheral. After each use, different information can be regenerated and stored in a preset location in the decryption peripheral for future use. Updating the information after each use can improve security.

[0123] Optionally, the decryption and identification program can be in the form of a DLL or SO file.

[0124] Optionally, before obtaining the target code file encrypted with the private key and the decryption assistance information, the method further includes:

[0125] Receives a verification code input by the user; the verification code is generated by the decryption peripheral based on the identifier code of the decryption peripheral and a timestamp;

[0126] In response to the user input, the step of obtaining decryption assistance information stored in the decryption peripheral is triggered.

[0127] Specifically, the decryption peripheral has a unique identifier. Based on the unique identifier and the current time information of the decryption peripheral, a random one-time verification code can be generated as the trigger condition for step 201, reducing the probability of decompilation.

[0128] Optionally, the decryption assistance information includes: code block splitting information and storage location information. The step of restoring the code of the decryption program, which is stored in the decryption peripheral device, according to the decryption assistance information to obtain the decryption program includes:

[0129] Based on the storage location information, multiple code blocks stored scattered in the decryption peripheral are obtained in a target order; the target order is an order other than the original order of the multiple code blocks in the decryption program.

[0130] Based on the code block splitting information and multiple code blocks, the decryption program is restored according to preset rules.

[0131] Here, the preset rule can be the reverse process of the preset rule used by the encryption end to split the code block.

[0132] Optionally, the decryption assistance information is bytecode; the storage location information in the bytecode includes at least one of the following: the starting position of the starting code block, the starting position of the ending code block, and the starting position of each code block.

[0133] Optionally, the method further includes:

[0134] Obtain the user authorization code and authorization certificate; the authorization certificate is the first part of the public key; obtain decryption assistance information based on the authorization certificate and target information.

[0135] The second part of the public key is stored in a distributed manner in the decryption peripheral. The decryption program and the public key are used to decrypt the encrypted target code file, including:

[0136] Obtain the second part of the public key that is stored in a distributed manner in the decryption peripheral;

[0137] The encrypted target code file is decrypted using the decryption program, the authorization certificate, and the second part of the public key.

[0138] Optionally, a randomly generated string can be used as the user authorization code.

[0139] The second part of the public key can be recovered based on the distributed storage method of the cryptographic party.

[0140] The method in this embodiment is similar to the encryption method embodiment in terms of its specific implementation process and technical effects. For details, please refer to the detailed description in the encryption method embodiment, which will not be repeated here.

[0141] The following describes the anti-reverse engineering encryption and decryption device provided by the present invention. The anti-reverse engineering encryption and decryption device described below can be referred to in correspondence with the anti-reverse engineering encryption and decryption method described above.

[0142] Figure 5 This is a schematic diagram of the anti-decompilation encryption device provided by the present invention. The anti-decompilation encryption device provided in this embodiment includes:

[0143] Encryption module 210 is used to encrypt the target code file using the obtained private key to obtain the encrypted target code file;

[0144] The processing module 220 is used to obtain decryption assistance information based on the public key corresponding to the private key and the target information; the target information includes at least one of the following: user authorization code and clock information of the decryption peripheral.

[0145] The processing module 220 is further configured to use the decryption assistance information to distribute and store the code of the decryption program in the decryption peripheral device; the decryption program is used to decrypt the encrypted target code file.

[0146] Optionally, the decryption auxiliary information includes: code block splitting information and storage location information, and the processing module 220 is specifically used for:

[0147] Based on the code block splitting information, the decryption program's code is split into multiple code blocks according to preset rules;

[0148] Based on the storage location information, the code blocks are distributed and stored in the decryption peripheral in a target order; the target order is an order other than the original order of the multiple code blocks in the decryption program.

[0149] Optionally, the decryption assistance information is bytecode; the storage location information in the bytecode includes at least one of the following: the starting position of the starting code block, the starting position of the ending code block, and the starting position of each code block.

[0150] Optionally, the processing module 220 is further configured to:

[0151] Based on the identification information of the target code file, determine whether the target code file needs to be encrypted;

[0152] If the target code file needs to be encrypted, then the step of encrypting the target code file using the obtained private key is performed.

[0153] Optionally, the identification information of the target code file includes a magic number; or,

[0154] The identification information of the target code file includes a magic number and at least one of the following: version number, file package name, class name, and descriptor;

[0155] The magic number is used to indicate the type of the target code file.

[0156] Optionally, the processing module 220 is further configured to:

[0157] Write the encryption identifier to a preset location in the encrypted target code file.

[0158] Optionally, the processing module 220 is further configured to:

[0159] Obtain user equipment information and user identification information. The user equipment information includes at least one of the following: CPU information, operating system information, and network card information.

[0160] Based on the user equipment information and user identification information, the private key and the corresponding public key are obtained using the target encryption algorithm;

[0161] Split the public key into a first part and a second part;

[0162] The first part is used as the authorization certificate, and the second part is stored separately in the decryption peripheral.

[0163] Optionally, the processing module 220 is specifically used for:

[0164] Decryption assistance information is obtained based on the authorization certificate and the target information.

[0165] Optionally, a randomly generated string can be used as the user authorization code.

[0166] The apparatus of this embodiment can be used to execute the method of any of the aforementioned encryption method embodiments. Its specific implementation process and technical effects are similar to those in the encryption method embodiments. For details, please refer to the detailed description in the method embodiments, which will not be repeated here.

[0167] Figure 6 This is a schematic diagram of the anti-decompilation decryption device provided by the present invention. The anti-decompilation decryption device provided in this embodiment includes:

[0168] The acquisition module 310 is used to acquire the target code file obtained by encrypting it with a private key and decryption assistance information; the decryption assistance information is obtained based on the public key corresponding to the private key and the target information, and the target information includes at least one of the following: user authorization code and clock information of the decryption peripheral;

[0169] Processing module 320 is used to restore the code of the decryption program stored in the decryption peripheral according to the decryption auxiliary information, so as to obtain the decryption program;

[0170] The decryption module 330 is used to decrypt the encrypted target code file using the decryption program and the public key.

[0171] Optionally, the decryption auxiliary information includes: code block splitting information and storage location information, and the processing module 320 is specifically used for:

[0172] Based on the storage location information, multiple code blocks stored scattered in the decryption peripheral are obtained in a target order; the target order is an order other than the original order of the multiple code blocks in the decryption program.

[0173] Based on the splitting information of the code blocks and the multiple code blocks, the decryption program is restored according to preset rules.

[0174] Optionally, the acquisition module 310 is further configured to:

[0175] Obtain the user authorization code and authorization certificate; the authorization certificate is the first part of the public key.

[0176] The decryption assistance information is obtained based on the authorization certificate and the target information;

[0177] The second part of the public key is distributed and stored in the decryption peripheral device, decryption module 330, which is specifically used for:

[0178] Obtain the second part of the public key that is stored in a distributed manner in the decryption peripheral;

[0179] The encrypted target code file is decrypted using the decryption program, the authorization certificate, and the second part of the public key.

[0180] Optionally, before acquiring the decryption auxiliary information stored in the decryption peripheral, the acquisition module 310 is further configured to: receive a verification code input by the user; the verification code is generated by the decryption peripheral based on the identification code of the decryption peripheral and a timestamp;

[0181] In response to the user input, the step of obtaining decryption assistance information stored in the decryption peripheral is triggered.

[0182] Optionally, the decryption assistance information is bytecode; the storage location information in the bytecode includes at least one of the following: the starting position of the starting code block, the starting position of the ending code block, and the starting position of each code block.

[0183] The apparatus of this embodiment can be used to execute the method of any of the aforementioned decryption method embodiments. Its specific implementation process and technical effects are similar to those of the decryption method embodiments. For details, please refer to the detailed description in the method embodiments, which will not be repeated here.

[0184] Figure 7 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 7 As shown, the electronic device may include: a processor 810, a communication interface 820, a memory 830, and a communication bus 840, wherein the processor 810, the communication interface 820, and the memory 830 communicate with each other via the communication bus 840. The processor 810 can call logical instructions in the memory 830 to execute anti-decompilation encryption and decryption methods, the encryption methods including:

[0185] The obtained private key is used to encrypt the target code file, resulting in the encrypted target code file;

[0186] Decryption assistance information is obtained based on the public key corresponding to the private key and the target information; the target information includes at least one of the following: user authorization code and clock information of the decryption peripheral;

[0187] Based on the decryption assistance information, the code of the decryption program is distributed and stored in the decryption peripheral; the decryption program is used to decrypt the encrypted target code file.

[0188] or,

[0189] The decryption method includes:

[0190] Obtain the target code file encrypted with the private key and decryption assistance information; the decryption assistance information is obtained based on the public key corresponding to the private key and the target information, and the target information includes at least one of the following: user authorization code and clock information of the decryption peripheral;

[0191] Based on the decryption assistance information, the code of the decryption program stored in the decryption peripheral is restored to obtain the decryption program.

[0192] The encrypted target code file is decrypted using the decryption program and public key.

[0193] Furthermore, the logical instructions in the aforementioned memory 830 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0194] On the other hand, the present invention also provides a computer program product, the computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions, wherein when the program instructions are executed by a computer, the computer is able to execute the anti-decompilation encryption and decryption methods provided by the above methods, the encryption method comprising:

[0195] The obtained private key is used to encrypt the target code file, resulting in the encrypted target code file;

[0196] Decryption assistance information is obtained based on the public key corresponding to the private key and the target information, wherein the target information includes at least one of the following: user authorization code and clock information of the decryption peripheral;

[0197] Based on the decryption assistance information, the code of the decryption program is distributed and stored in the decryption peripheral; the decryption program is used to decrypt the encrypted target code file.

[0198] or,

[0199] The decryption method includes:

[0200] Obtain the target code file encrypted with the private key and decryption assistance information; the decryption assistance information is obtained based on the public key corresponding to the private key and the target information, and the target information includes at least one of the following: user authorization code and clock information of the decryption peripheral;

[0201] Based on the decryption assistance information, the code of the decryption program stored in the decryption peripheral is restored to obtain the decryption program.

[0202] The encrypted target code file is decrypted using the decryption program and public key.

[0203] In another aspect, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the aforementioned anti-decompilation encryption and decryption methods, the encryption method comprising:

[0204] The obtained private key is used to encrypt the target code file, resulting in the encrypted target code file;

[0205] Decryption assistance information is obtained based on the public key corresponding to the private key and the target information; the target information includes at least one of the following: user authorization code and clock information of the decryption peripheral;

[0206] Based on the decryption assistance information, the code of the decryption program is distributed and stored in the decryption peripheral; the decryption program is used to decrypt the encrypted target code file.

[0207] or,

[0208] The decryption method includes:

[0209] Obtain the target code file encrypted with the private key and decryption assistance information; the decryption assistance information is obtained based on the public key corresponding to the private key and the target information, and the target information includes at least one of the following: user authorization code and clock information of the decryption peripheral;

[0210] Based on the decryption assistance information, the code of the decryption program stored in the decryption peripheral is restored to obtain the decryption program.

[0211] The encrypted target code file is decrypted using the decryption program and public key.

[0212] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0213] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0214] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A decompilation-resistant encryption method, characterized in that, include: The obtained private key is used to encrypt the target code file, resulting in the encrypted target code file; Decryption assistance information is obtained based on the public key corresponding to the private key and the target information; The target information includes at least one of the following: user authorization code and clock information of the decryption peripheral; the decryption auxiliary information includes: code block splitting information and storage location information; Based on the code block splitting information, the decryption program's code is split into multiple code blocks according to preset rules; According to the storage location information, the code blocks are distributed and stored in the decryption peripheral in a target order; the target order is an order other than the original order of the multiple code blocks in the decryption program; the decryption program is used to decrypt the encrypted target code file.

2. The method according to claim 1, characterized in that, The decryption assistance information is bytecode; the storage location information in the bytecode includes at least one of the following: the starting position of the starting code block, the starting position of the ending code block, and the starting position of each code block.

3. The method according to any one of claims 1-2, characterized in that, Before encrypting the target code file using the obtained private key, the process also includes: Based on the identification information of the target code file, determine whether the target code file needs to be encrypted; If the target code file needs to be encrypted, then the step of encrypting the target code file using the obtained private key is performed.

4. The method according to claim 3, characterized in that, The identification information of the target code file includes a magic number; or, The identification information of the target code file includes a magic number and at least one of the following: version number, file package name, class name, and descriptor; The magic number is used to indicate the type of the target code file.

5. The method according to any one of claims 1-2, characterized in that, After encrypting the target code file using the obtained private key, the process further includes: Write the encryption identifier to a preset location in the encrypted target code file.

6. The method according to any one of claims 1-2, characterized in that, The method further includes: Obtain user equipment information and user identification information. The user equipment information includes at least one of the following: CPU information, operating system information, and network card information. Based on the user equipment information and user identification information, the private key and the corresponding public key are obtained using the target encryption algorithm; Split the public key into a first part and a second part; The first part is used as the authorization certificate, and the second part is stored separately in the decryption peripheral.

7. The method according to claim 6, characterized in that, Based on the public key corresponding to the private key and the target information, decryption assistance information is obtained, including: Decryption assistance information is obtained based on the authorization certificate and target information.

8. A decryption method to prevent reverse engineering, characterized in that, include: Obtain the target code file encrypted with the private key, along with decryption assistance information; The decryption assistance information is obtained based on the public key corresponding to the private key and the target information. The target information includes at least one of the following: user authorization code and clock information of the decryption peripheral. The target code file obtained by encrypting with the private key and the decryption assistance information are obtained by any of the anti-reverse compilation encryption methods described in claims 1-7. Based on the decryption assistance information, the code of the decryption program stored in the decryption peripheral is restored to obtain the decryption program. The encrypted target code file is decrypted using the decryption program and public key.

9. The method according to claim 8, characterized in that, The decryption assistance information includes: code block splitting information and storage location information. Based on the decryption assistance information, the code of the decryption program, which is stored in the decryption peripheral, is restored to obtain the decryption program, including: Based on the storage location information, multiple code blocks stored scattered in the decryption peripheral are obtained in a target order; the target order is an order other than the original order of the multiple code blocks in the decryption program. Based on the splitting information of the code blocks and the multiple code blocks, the decryption program is restored according to preset rules.

10. The method according to claim 8 or 9, characterized in that, The method further includes: Obtain the user authorization code and authorization certificate; the authorization certificate is the first part of the public key. The decryption assistance information is obtained based on the authorization certificate and the target information; The second part of the public key is stored in a distributed manner in the decryption peripheral. The decryption program and the public key are used to decrypt the encrypted target code file, including: Obtain the second part of the public key that is stored in a distributed manner in the decryption peripheral; The encrypted target code file is decrypted using the decryption program, the authorization certificate, and the second part of the public key.

11. The method according to claim 8 or 9, characterized in that, Before obtaining the target code file encrypted with the private key and the decryption assistance information, the process also includes: Receives a verification code input by the user; the verification code is generated by the decryption peripheral based on the identifier code of the decryption peripheral and a timestamp; In response to the user input, the step of obtaining decryption assistance information stored in the decryption peripheral is triggered.

12. The method according to claim 8 or 9, characterized in that, The decryption assistance information is bytecode; the storage location information in the bytecode includes at least one of the following: the starting position of the starting code block, the starting position of the ending code block, and the starting position of each code block.

13. An anti-reverse engineering encryption device, characterized in that, include: The encryption module is used to encrypt the target code file using the obtained private key, resulting in an encrypted target code file. The processing module is used to obtain decryption assistance information based on the public key corresponding to the private key and the target information; The target information includes at least one of the following: user authorization code and clock information of the decryption peripheral; the decryption auxiliary information includes: code block splitting information and storage location information; The processing module is further configured to split the code of the decryption program into multiple code blocks according to the code block splitting information and a preset rule; and to disperse and store the code blocks in the decryption peripheral according to the storage location information and a target order; the target order is an order other than the original order of the multiple code blocks in the decryption program; the decryption program is used to decrypt the encrypted target code file.

14. A decryption device to prevent reverse engineering, characterized in that, include: The acquisition module is used to acquire the target code file encrypted with the private key and decryption assistance information; The decryption assistance information is obtained based on the public key corresponding to the private key and the target information. The target information includes at least one of the following: user authorization code and clock information of the decryption peripheral. The target code file obtained by encrypting with the private key and the decryption assistance information are obtained by any of the anti-reverse compilation encryption methods described in claims 1-7. The processing module is used to restore the code of the decryption program that is scattered in the decryption peripheral according to the decryption auxiliary information, so as to obtain the decryption program; The decryption module is used to decrypt the encrypted target code file using the decryption program and the public key.

15. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the anti-decompilation encryption method as described in any one of claims 1 to 7, or the anti-decompilation decryption method as described in any one of claims 8 to 12.

16. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the anti-decompilation encryption method as described in any one of claims 1 to 7 or the anti-decompilation decryption method as described in any one of claims 8 to 12.

17. A computer program product having executable instructions stored thereon, characterized in that, When executed by the processor, this instruction causes the processor to implement the anti-decompilation encryption method as described in any one of claims 1 to 7 or the anti-decompilation decryption method as described in any one of claims 8 to 12.

Citation Information

Patent Citations

  • Soft secret key system and implementation method

    CN104579689A

  • Finite state machine-based source code enhancement method and apparatus

    CN108415709A