A method, apparatus and electronic device for encrypting and decrypting program files

By using license information and keys generated by the certification authority in Java programs to encrypt and decrypt program files, combined with class library files and probe programs, the problem of easy leakage of Java intermediate code is solved, and effective protection and access control of programs are achieved.

CN115688134BActive Publication Date: 2026-05-26NANJING SIWEI ZHILIAN TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
NANJING SIWEI ZHILIAN TECH CO LTD
Filing Date
2022-10-28
Publication Date
2026-05-26

AI Technical Summary

Technical Problem

In existing technologies, the intermediate code of the Java programming language is easily decompiled, leading to source code leakage, and the startup and running permissions of the program cannot be effectively controlled.

Method used

By obtaining the target program, encryption configuration file, and license application information from the package to be encrypted, the system generates license information and keys using the certification authority, generates encrypted files and decryption programs, and associates them with library files and probe programs to achieve program encryption and decryption.

Benefits of technology

It enhances the protection of program source code, flexibly controls the program's execution lifespan and startup permissions, prevents source code leakage, and reduces the protection and control considerations developers need when writing source code.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115688134B_ABST
    Figure CN115688134B_ABST
Patent Text Reader

Abstract

This invention discloses a method, apparatus, and electronic device for encrypting and decrypting program files. The encryption method involves obtaining the target program to be encrypted, the encryption configuration file, and the corresponding license application information of the target program from the program package to be encrypted; determining the encryption method of the target program based on the encryption configuration file; sending corresponding target data to an authentication center according to the different encryption methods; receiving the key corresponding to the target program returned by the authentication center; obtaining a first encrypted file containing the encrypted target program and a second encrypted file containing the corresponding license information; generating a corresponding decryption program based on the first and second encrypted files; generating a class library file corresponding to the decryption program and a probe program corresponding to the class library file according to a preset method; and associating the first encrypted file, the second encrypted file, the class library file, and the probe program to increase the difficulty of obtaining the source code files in the program file.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of program security processing technology, specifically to a method, apparatus, and electronic device for encrypting and decrypting program files. Background Technology

[0002] Currently, programming languages ​​are widely used for development in the internet and traditional service sectors. Many programming languages ​​possess excellent characteristics such as cross-platform compatibility and ease of use, such as the Java programming language. Java can be compiled once and run anywhere; as long as a Java Virtual Machine (JVM) is installed in the environment, Java programs can run. Java is an interpreted language; the compiler transforms Java code into intermediate code, which is then parsed and executed on the JVM. Because the intermediate code is platform-independent, Java can execute well across platforms and has good portability. However, the intermediate code contains information about the source code, making it easy to obtain the source code through decompilation.

[0003] To improve source code security and prevent leaks, a common primary measure is to obfuscate the programming language code. Obfuscating code transforms it into a difficult-to-read format, increasing the difficulty of cracking. However, after a series of logical checks, the obfuscated code can be restored to its original logic, revealing the original source code. For example, the obfuscated compiled class file can be encrypted and decrypted using a custom class loader. However, since the custom class loader itself is not encrypted, its decryption logic and methods are easily exposed, allowing manual identification to reveal the original code. If runtime control is required, encryption and obfuscation alone, while preventing code leaks in some scenarios, cannot achieve complete control over program startup and execution permissions. Summary of the Invention

[0004] Therefore, the technical problem to be solved by the present invention is to overcome the shortcomings of existing methods that easily leak source code and cannot control the startup and running permissions of programs, thereby providing a method, device and electronic device for encrypting and decrypting program files.

[0005] According to a first aspect, embodiments of the present invention disclose a method for encrypting program files, comprising: obtaining a target program to be encrypted, an encryption configuration file, and license application information corresponding to the target program from a program package to be encrypted; determining the encryption method of the target program according to the encryption configuration file, wherein the encryption method includes local encryption and remote encryption; sending corresponding target data to an authentication center according to the different encryption methods, such that the authentication center generates license information corresponding to the target program and keys required for encryption and decryption based on the target data, wherein the target data includes license application information; receiving the key corresponding to the target program returned by the authentication center; obtaining a first encrypted file containing the encrypted target program and a second encrypted file containing the corresponding license information; generating a corresponding decryption program based on the first encrypted file and the second encrypted file; generating a class library file corresponding to the decryption program and a probe program corresponding to the class library file according to a preset method; and associating the first encrypted file, the second encrypted file, the class library file, and the probe program.

[0006] Optionally, the step of sending corresponding target data to the certification center according to different encryption methods, so that the certification center generates license information corresponding to the target program and the keys required for encryption and decryption based on the target data, includes: when the encryption method of the target program is local encryption, sending license application information to the certification center, so that the certification center generates license information corresponding to the target program and the keys required for local encryption and decryption based on the license application information;

[0007] The step of obtaining a first encrypted file containing the encrypted target program and a second encrypted file containing the corresponding license information includes: encrypting the target program using the key to obtain the first encrypted file; and encrypting the license information using the key to obtain the second encrypted file.

[0008] Optionally, the step of sending corresponding target data to the certification center according to different encryption methods, so that the certification center generates license information corresponding to the target program and keys required for encryption and decryption based on the target data, includes: when the encryption method of the target program is remote encryption, sending the license application information and the target program to the certification center, so that the certification center generates license information corresponding to the target program based on the license application information, and encrypts the target program using the key to obtain a first encrypted file, and encrypts the license information using the key to obtain a second encrypted file;

[0009] The step of obtaining a first encrypted file containing the encrypted target program and a second encrypted file containing the corresponding license information includes: receiving the first encrypted file and the second encrypted file returned by the certification center.

[0010] Optionally, after obtaining the first encrypted file containing the encrypted target program and the second encrypted file containing the corresponding license information, the method further includes: replacing the target program in the package to be encrypted containing the target program using the first encrypted file.

[0011] Optionally, after generating the class library file corresponding to the decryption program and the probe program corresponding to the class library file according to the preset method, the method further includes: hardening the class library file.

[0012] Optionally, the method further includes: when receiving new license application information corresponding to the target program, sending the new license application information to the certification center, so that when the certification center determines that the usage period permission contained in the new license application information has been extended and the new license application information meets the renewal conditions, it regenerates the license information corresponding to the target program.

[0013] According to a second aspect, embodiments of the present invention also disclose a program file decryption method, comprising: when a running request of a target program corresponding to a file to be decrypted is detected, controlling a probe program corresponding to the file to be decrypted to start running, wherein the file to be decrypted is obtained by a program file encryption method as described in the first aspect or any optional embodiment of the first aspect; loading a corresponding class library file according to the probe program corresponding to the file to be decrypted, and decrypting the file to be decrypted.

[0014] Optionally, the corresponding class library file is loaded according to the probe program corresponding to the file to be decrypted, and the file to be decrypted is decrypted, including: using the class library file to decrypt the license information to be decrypted corresponding to the file to be decrypted, to obtain a first decrypted file; determining whether the license of the file to be decrypted is within the authentication exemption period based on the first decrypted file; if the license of the file to be decrypted is within the authentication exemption period, then the decryption operation of the file to be decrypted is performed.

[0015] Optionally, after determining whether the license of the file to be decrypted is within the authentication-free period based on the first decrypted file, the method further includes: if the license of the file to be decrypted is not within the authentication-free period, requesting the certification center to verify the license information of the file to be decrypted; receiving the verification result returned by the certification center; if the verification result is that the license of the file to be decrypted has not expired, updating the license information of the file to be decrypted, and performing the decryption operation on the file to be decrypted.

[0016] According to a third aspect, embodiments of the present invention also disclose a program file encryption device, comprising: a first acquisition module, configured to acquire a target program to be encrypted, an encryption configuration file, and license application information corresponding to the target program from a program package to be encrypted; a first determination module, configured to determine the encryption method of the target program according to the encryption configuration file, the encryption method including local encryption and remote encryption; a first sending module, configured to send corresponding target data to an authentication center according to different encryption methods, such that the authentication center generates license information corresponding to the target program and keys required for encryption and decryption based on the target data, the target data including license application information; a receiving module, configured to receive the key corresponding to the target program returned by the authentication center; a second acquisition module, configured to acquire a first encrypted file containing the encrypted target program and a second encrypted file containing the corresponding license information; a second determination module, configured to generate a corresponding decryption program based on the first encrypted file and the second encrypted file; a third determination module, configured to generate a class library file corresponding to the decryption program and a probe program corresponding to the class library file according to a preset method; and an association module, configured to associate the first encrypted file, the second encrypted file, the class library file, and the probe program.

[0017] According to a fourth aspect, embodiments of the present invention also disclose a program file decryption device, comprising: a calling module, configured to control a probe program corresponding to the file to be decrypted to start running when a running request of a target program corresponding to the file to be decrypted is detected, wherein the file to be decrypted is obtained by a program file encryption method as described in the first aspect or any optional embodiment of the first aspect; and a decryption module, configured to load a corresponding class library file according to the probe program corresponding to the file to be decrypted, and decrypt the file to be decrypted.

[0018] According to a fifth aspect, embodiments of the present invention also disclose an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to cause the at least one processor to perform steps of a program file encryption method as described in the first aspect or any optional embodiment of the first aspect, or to perform steps of a program file decryption method as described in the second aspect or any optional embodiment of the second aspect.

[0019] According to a sixth aspect, embodiments of the present invention also disclose a 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 program file encryption method as described in the first aspect or any optional embodiment of the first aspect, or implements the steps of the program file decryption method as described in the second aspect or any optional embodiment of the second aspect.

[0020] The technical solution of this invention has the following advantages:

[0021] The program file encryption method / apparatus provided by this invention obtains the target program to be encrypted, the encryption configuration file, and the license application information corresponding to the target program from the program package to be encrypted. It determines the encryption method of the target program based on the encryption configuration file. Depending on the encryption method, it sends corresponding target data to an authentication center, enabling the authentication center to generate license information corresponding to the target program and the keys required for encryption and decryption based on the target data. It then receives the keys corresponding to the target program returned by the authentication center. The method further obtains a first encrypted file containing the encrypted target program and a second encrypted file containing the corresponding license information. Based on the first and second encrypted files, it generates a corresponding decryption program. It generates a class library file corresponding to the decryption program and a probe program corresponding to the class library file according to a preset method. Associating the first encrypted file, the second encrypted file, the class library file, and the probe program increases the difficulty of obtaining the source code files in the program file, thereby improving the protection of the program source code. Simultaneously, associating the program file with the corresponding license information allows for flexible updating and modification of the execution lifespan of the controlled program, facilitating subsequent control of the program's startup and operation based on the corresponding license information, effectively controlling the negative impact of program leakage. Attached Figure Description

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

[0023] Figure 1 This is a flowchart illustrating a specific example of a program file encryption method in an embodiment of the present invention;

[0024] Figure 2 This is a flowchart illustrating a specific example of a program file decryption method in an embodiment of the present invention;

[0025] Figure 3 This is a schematic diagram illustrating a specific example of a program file encryption device in an embodiment of the present invention.

[0026] Figure 4 This is a schematic diagram illustrating a specific example of a program file decryption device in an embodiment of the present invention.

[0027] Figure 5 This is a specific example diagram of an electronic device in an embodiment of the present invention. Detailed Implementation

[0028] The technical solution of the present invention will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0029] In the description of this invention, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are used only for the convenience of describing the invention and for simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on the invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.

[0030] In the description of this invention, it should be noted that, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; they can also refer to the internal connection of two components; and they can refer to a wireless connection or a wired connection. Those skilled in the art can understand the specific meaning of the above terms in this invention based on the specific circumstances.

[0031] Furthermore, the technical features involved in the different embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.

[0032] This invention discloses a method for encrypting program files. In this embodiment, the encryption method can be applied to an encryption plugin, which can be actual developed software or exist in various other forms, such as executable programs, Maven plugins, etc. Figure 1 As shown, the method includes the following steps:

[0033] Step 101: Obtain the target program to be encrypted, the encryption configuration file, and the license application information corresponding to the target program from the program package to be encrypted.

[0034] For example, the package to be encrypted can be any file package containing the target program, and the target program can be any program in the package to be encrypted that needs to be encrypted. In this embodiment, the target program can be key information extracted from the class file obtained after compiling the program (Java programming language) to be encrypted. The class file is a binary file that can run on any hardware platform and operating system that supports the Java Virtual Machine. The package to be encrypted can be a collection of class files compiled from the program to be encrypted. The encryption configuration file can be a configuration file containing the encryption method and encryption content of the target program, and the license application information can be the license startup permission information of the target program.

[0035] Step 102: Determine the encryption method of the target program according to the encryption configuration file. The encryption method includes local encryption and remote encryption.

[0036] For example, local encryption can be implemented by the encryption module in the encryption plugin to encrypt the target program, while remote encryption can be implemented by encrypting the target program through a preset encryption platform. In this embodiment, the preset encryption platform may include, but is not limited to, an authentication center.

[0037] Step 103: Based on the different encryption methods, send the corresponding target data to the certification center, so that the certification center can generate the license information corresponding to the target program and the keys required for encryption and decryption based on the target data. The target data includes license application information.

[0038] For example, the certification center can be a license management and authorization platform. In this embodiment, when the encryption method is local encryption, the target data sent to the certification center can be the corresponding license application information. The certification center will use a preset encryption method to generate a key and corresponding license information corresponding to the license application information. The license information can include basic information of the target program, authorization date, authorization termination date, and certification exemption date. The preset encryption method can include, but is not limited to, symmetric encryption algorithms and asymmetric encryption algorithms. In this embodiment, an asymmetric encryption algorithm can be used to generate the public and private key pair corresponding to the license application information. When the encryption method is remote encryption, the target data can be the target program and the license application information. The certification center will encrypt the target program and the license application information according to the generated key. At the same time, the certification center saves the uniqueness of the public key, private key, and license application information as a primary key in the database (or cache). In this embodiment, information can be transmitted between the encryption plugin and the certification center through an encrypted link, thereby preventing the leakage of transmitted information.

[0039] In this embodiment, when the authentication center receives the license application information of the target program sent by the encryption plugin, it reads the user information corresponding to the target program; compares the user information corresponding to the target program with the preset user information with usage permissions to determine whether the user corresponding to the target program has usage permissions; if the user corresponding to the target program has usage permissions, it performs the subsequent key pair and license information generation operation; if the user corresponding to the target program does not have usage permissions, it refuses to provide services to him / her.

[0040] Step 104: Receive the key corresponding to the target program returned by the authentication center.

[0041] For example, in this embodiment of the application, the encryption method preset by the certification center can be an asymmetric encryption algorithm. When the encryption method is local encryption, the encryption plugin will receive the public and private key pair returned by the certification center, so that the encryption plugin can subsequently encrypt the target program and the corresponding license information according to the private key, and generate the corresponding decryption program according to the public key. When the encryption method is remote encryption, the encryption plugin will receive the public key returned by the certification center, so that the encryption plugin can subsequently use the public key to generate the corresponding decryption program.

[0042] Step 105: Obtain a first encrypted file containing the encrypted target program and a second encrypted file containing the corresponding license information.

[0043] For example, in this embodiment of the application, when the encryption method is local encryption, the target program and the corresponding license information are encrypted according to the private key returned by the certification center to obtain the first encrypted file and the second encrypted file; when the encryption method is remote encryption, the first encrypted file and the second encrypted file are received directly from the certification center.

[0044] Step 106: Generate a corresponding decryption program based on the first encrypted file and the second encrypted file.

[0045] For example, in the embodiments of this application, the decryption programs corresponding to the first and second encrypted files may include, but are not limited to, the corresponding public keys, communication protocols with the certification center, and decryption logic methods. Specifically, the decryption programs for the first and second encrypted files can be written based on the public keys. For example, the execution logic of the decryption program can be to first decrypt the second encrypted file to obtain license information, determine whether the license information has decryption permission, and if decryption permission is granted, then decrypt the first encrypted file. To further increase the difficulty of decompilation and improve security, the decryption logic in the decryption program can be written in C / C++. After compilation in C or C++, it cannot be restored to source code, thus possessing inherent anti-decompilation characteristics.

[0046] Step 107: Generate the class library file corresponding to the decryption program and the probe program corresponding to the class library file according to the preset method.

[0047] For example, library files can include, but are not limited to, Windows DLL files or Linux .so files. In this embodiment, the library file can be a Linux .so file. .so files are called shared libraries, which depend on the development platform and cannot be run independently. Specifically, a JVMTIAgent written in C or C++ can be implemented as a library using the JVMTI (JVM Tool Interface) architecture of JPDA (Java Platform Debugging Architecture). JPDA is a multi-layered debugging architecture that allows tool developers to easily create debugger applications that can run cross-platform, virtual machine (VM) implemented, and JDK version-compatiblely. The probe program (Javaagent program) is used to bundle the library file so that it can be automatically loaded at runtime. According to the JVMTI protocol, after the program runs, it will automatically call back the callback methods in the library, thereby activating the predefined decryption and control management processes in the library and performing normal decryption logic.

[0048] Step 108: Associate the first encrypted file, the second encrypted file, the library file, and the probe program. For example, associating the first encrypted file, the second encrypted file, the library file, and the probe program facilitates subsequent decryption operations.

[0049] The program file encryption method provided by this invention obtains the target program to be encrypted, the encryption configuration file, and the license application information corresponding to the target program from the program package to be encrypted. Based on the encryption configuration file, the encryption method of the target program is determined. Depending on the encryption method, corresponding target data is sent to an authentication center, enabling the authentication center to generate license information corresponding to the target program and the keys required for encryption and decryption based on the target data. The method then receives the key corresponding to the target program returned by the authentication center. A first encrypted file containing the encrypted target program and a second encrypted file containing the corresponding license information are obtained. A corresponding decryption program is generated based on the first and second encrypted files. A class library file corresponding to the decryption program and a probe program corresponding to the class library file are generated according to a preset method. Associating the first encrypted file, the second encrypted file, the class library file, and the probe program increases the difficulty of obtaining the source code files in the program file, thereby improving the protection of the program code. Simultaneously, associating the program file with the corresponding license information allows for flexible updating and modification of the execution lifespan of the controlled program, facilitating subsequent control of the program's startup and operation based on the corresponding license information, effectively controlling the negative impact of program leakage.

[0050] Typically, when encrypting Java programs, developers need to write class loaders to perform operations such as class decryption, which is not very developer-friendly. Using the program file encryption method implemented in this application eliminates the need to consider program protection, encryption, and control issues when writing the source code. Simply configure the corresponding configuration file and import the encryption plugin to encrypt Java programs normally, with minimal impact on developers.

[0051] As an optional embodiment of the present invention, step 103 above includes: when the encryption method of the target program is local encryption, sending license application information to the certification center, so that the certification center generates license information corresponding to the target program and the keys required for local encryption and decryption based on the license application information. Exemplarily, in this embodiment, when the encryption method is local encryption, the encryption plugin sends the license application information of the target program to the certification center. The certification center generates corresponding license information and a public / private key pair based on the received license application information. Then, the certification center sends the license information and the public / private key pair to the encryption plugin via an encrypted link.

[0052] Step 105 above includes: encrypting the target program using the key to obtain a first encrypted file; and encrypting the license information using the key to obtain a second encrypted file. Exemplarily, in this embodiment, when the encryption plugin receives the license information and public / private key pair sent by the certification authority, it encrypts the target program using the private key to obtain the first encrypted file, and encrypts the license information using the private key to obtain the second encrypted file.

[0053] As an optional embodiment of the present invention, step 103 above includes: when the encryption method of the target program is remote encryption, sending the license application information and the target program to the certification center, so that the certification center generates license information corresponding to the target program according to the license application information, and encrypts the target program using a key to obtain a first encrypted file, and encrypts the license information using the key to obtain a second encrypted file. Exemplarily, in this embodiment, when the encryption method is remote encryption, the certification center encrypts the target program using a private key to obtain a first encrypted file, encrypts the license information using a private key to obtain a second encrypted file, and sends the first and second encrypted files to the encryption plugin.

[0054] Step 105 above includes: receiving a first encrypted file and a second encrypted file returned by the authentication center. For example, the encryption plugin receives the first encrypted file and the second encrypted file returned by the authentication center.

[0055] As an optional embodiment of the present invention, after step 105, the method further includes: replacing the target program in the package to be encrypted containing the target program with the first encrypted file. For example, replacing the target program in the package to be encrypted with the first encrypted file facilitates the protection of the target program's security.

[0056] As an optional embodiment of the present invention, after step 107, the method further includes: hardening the library file. Exemplarily, in this embodiment, hardening and obfuscating the library file can greatly increase the difficulty of cracking the library file.

[0057] As an optional embodiment of the present invention, the method further includes: when receiving new license application information corresponding to the target program, sending the new license application information to the certification center, so that when the certification center determines that the usage period permission contained in the new license application information has been extended and the new license application information meets the renewal conditions, it regenerates the license information corresponding to the target program.

[0058] For example, when the encryption plugin receives new license application information for the target program, it can determine whether renewal is required based on the new license application information. If renewal is required, the new license application information is sent to the certification authority. When the certification authority determines that the usage period permissions contained in the new license application information have been extended and that the new license application information meets the renewal conditions, it regenerates new license information for the target program based on the license application information. The certification authority encrypts the new license information using the corresponding private key and sends the encrypted new license information to the encryption plugin. Upon receiving the encrypted new license information, the encryption plugin replaces the original license information (the second encrypted file). Subsequent decryption operations on the target program will use the new license information to decrypt the target program.

[0059] This invention discloses a method for decrypting program files, which can be used to decrypt plugins, such as... Figure 2 As shown, the method includes the following steps:

[0060] Step 201: When a running request of the target program corresponding to the file to be decrypted is detected, the probe program corresponding to the file to be decrypted is controlled to start running. The file to be decrypted is obtained by the program file encryption method as described in the above embodiment.

[0061] For example, in this embodiment of the application, when the target program corresponding to the file to be decrypted needs to run, the probe program corresponding to the file to be decrypted will run automatically and load the corresponding decryption library. For example, when a program A needs to be run, the probe program corresponding to program A will run automatically and load the corresponding decryption library. The decryption library will receive the decryption request of the file a to be decrypted corresponding to program A and can decrypt the file a to be decrypted.

[0062] Step 202: Load the corresponding class library file according to the probe program corresponding to the file to be decrypted, and decrypt the file to be decrypted.

[0063] For example, the probe program automatically loads the corresponding library file from the local library. After the library file is initialized, it automatically decrypts the file to be decrypted. In this embodiment, when the corresponding library file performs the decryption operation on the file to be decrypted, it can determine whether to decrypt the file based on the license information corresponding to the file to be decrypted. Specifically, it can determine whether to decrypt the file based on information such as the authorization date, authorization expiration date, and exemption date contained in the license information, effectively controlling the negative impact caused by program leakage.

[0064] The program file decryption method provided by this invention, when a running request of the target program corresponding to the file to be decrypted is detected, the corresponding probe program starts running, loads the corresponding class library file, and decrypts the file to be decrypted, thereby improving the protection of the program source code. At the same time, the corresponding class library file performs the decryption operation on the file to be decrypted, effectively controlling the negative impact caused by program leakage.

[0065] As an optional embodiment of the present invention, step 202 above includes: using the class library file to decrypt the license information corresponding to the file to be decrypted, thereby obtaining a first decrypted file. For example, when the class library file is executed, it first decrypts the license information corresponding to the file to be decrypted, obtaining the decrypted license information.

[0066] Based on the first decryption file, determine whether the license of the file to be decrypted is within the authentication-free period; if the license of the file to be decrypted is within the authentication-free period, then perform the decryption operation on the file to be decrypted. For example, if it is determined from the information in the first decryption file that the file to be decrypted is within the authentication-free period, it means that the current license allows the program to execute, the logic corresponding to the class library file is valid, and the decryption operation on the file to be decrypted can continue.

[0067] As an optional embodiment of the present invention, after determining whether the license of the file to be decrypted is within the certification-free period based on the first decrypted file, the method further includes: if the license of the file to be decrypted is not within the certification-free period, requesting the certification center to verify the license information of the file to be decrypted; receiving the verification result returned by the certification center; if the verification result is that the license of the file to be decrypted has not expired, updating the license information of the file to be decrypted, and performing the decryption operation on the file to be decrypted.

[0068] For example, if the file to be decrypted is not within the authentication-free period, a new license needs to be obtained from the certification authority. Only after the license is updated can the decryption program be executed. If the certification authority determines that the license for the file to be decrypted has expired, the certification authority will not issue a new license, the file to be decrypted cannot be decrypted, the program ends, and the purpose of controlling program startup permissions is achieved.

[0069] This invention also discloses a program file encryption device, such as... Figure 3 As shown, the device includes: a first acquisition module 301, used to acquire the target program to be encrypted, the encryption configuration file, and the license application information corresponding to the target program from the program package to be encrypted; a first determination module 302, used to determine the encryption method of the target program according to the encryption configuration file, the encryption method including local encryption and remote encryption; a first sending module 303, used to send corresponding target data to the certification center according to the different encryption methods, so that the certification center generates the license information corresponding to the target program and the key required for encryption and decryption according to the target data, the target data including the license application information; a receiving module 304, used to receive the key corresponding to the target program returned by the certification center; a second acquisition module 305, used to acquire a first encrypted file containing the encrypted target program and a second encrypted file containing the corresponding license information; a second determination module 306, used to generate a corresponding decryption program according to the first encrypted file and the second encrypted file; a third determination module 307, used to generate a class library file corresponding to the decryption program and a probe program corresponding to the class library file according to a preset method; and an association module 308, used to associate the first encrypted file, the second encrypted file, the class library file, and the probe program.

[0070] The program file encryption device provided by this invention increases the difficulty of obtaining the source code file in the program file, thereby improving the protection of the program code. At the same time, by associating the program file with the corresponding license information, the execution life of the controlled program can be flexibly updated and modified, which facilitates subsequent control of the program's startup and operation based on the corresponding license information, effectively controlling the negative impact caused by program leakage.

[0071] As an optional embodiment of the present invention, the first sending module includes: a first sending submodule, configured to send license application information to the certification center when the encryption method of the program to be encrypted is local encryption, so that the certification center generates license information corresponding to the program to be encrypted and the key required for local encryption and decryption based on the license application information;

[0072] The second acquisition module includes: a determination submodule, used to encrypt the target program using the key to obtain a first encrypted file; and an encryption submodule, used to encrypt the license information using the key to obtain a second encrypted file.

[0073] As an optional embodiment of the present invention, the first sending module includes: a second sending submodule, used to send the license application information and the target program to the certification center when the encryption method of the program to be encrypted is remote encryption, so that the certification center generates license information corresponding to the program to be encrypted according to the license application information, and encrypts the target program with a key to obtain a first encrypted file, and encrypts the license information with the key to obtain a second encrypted file;

[0074] The second acquisition module includes a receiving submodule, used to receive the first encrypted file and the second encrypted file returned by the authentication center.

[0075] As an optional embodiment of the present invention, the apparatus further includes: a replacement module, used to replace the target program in the package to be encrypted containing the target program using the first encrypted file.

[0076] As an optional embodiment of the present invention, the device further includes: a hardening module for hardening the class library file.

[0077] As an optional embodiment of the present invention, the apparatus further includes: a second sending module, configured to send the new license application information to an authentication center when a new license application information corresponding to the target program is received, so that when the authentication center determines that the usage period permission contained in the new license application information has been extended and the new license application information meets the renewal conditions, it regenerates the license information corresponding to the target program.

[0078] This invention also discloses a program file decryption device, such as... Figure 4As shown, the device includes: a calling module 501, used to control the probe program corresponding to the file to be decrypted to start running when a running request of the target program corresponding to the file to be decrypted is detected, wherein the file to be decrypted is obtained by the program file encryption method described in the above embodiment; and a decryption module 502, used to load the corresponding class library file according to the probe program corresponding to the file to be decrypted, and decrypt the file to be decrypted.

[0079] The program file decryption device provided by the invention, when detecting the running request of the target program corresponding to the file to be decrypted, starts the corresponding probe program, loads the corresponding class library file, and decrypts the file to be decrypted, thereby improving the protection of the program source code. At the same time, when the corresponding class library file performs the decryption operation on the file to be decrypted, it can determine whether to decrypt the file to be decrypted based on the license information corresponding to the file to be decrypted, effectively controlling the negative impact caused by program leakage.

[0080] As an optional embodiment of the present invention, the decryption module includes: a first decryption submodule, used to decrypt the file to be decrypted by reading the license information corresponding to the file to be decrypted from the class library file to obtain a first decrypted file; a judgment submodule, used to determine whether the license of the file to be decrypted is within the authentication exemption period based on the first decrypted file; and a second decryption submodule, used to perform a decryption operation on the file to be decrypted when the license of the file to be decrypted is within the authentication exemption period.

[0081] As an optional embodiment of the present invention, the apparatus further includes: a request verification module, configured to request a certification center to verify the license information of the file to be decrypted when the license of the file to be decrypted is not within the certification-free period; a verification result receiving module, configured to receive the verification result returned by the certification center; and an update module, configured to update the license information of the file to be decrypted and perform a decryption operation on the file to be decrypted when the verification result indicates that the license of the file to be decrypted has not expired.

[0082] This invention also provides an electronic device, such as... Figure 5 As shown, the electronic device may include a processor 401 and a memory 402, wherein the processor 401 and the memory 402 may be connected via a bus or other means. Figure 5 Taking the example of a connection between China and Israel via a bus.

[0083] Processor 401 may be a central processing unit (CPU). Processor 401 may also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or combinations thereof.

[0084] The memory 402, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs, non-transitory computer-executable programs, and modules, such as the program instructions / modules corresponding to the program file encryption method or program file decryption method in the embodiments of the present invention. The processor 401 executes various functional applications and data processing by running the non-transitory software programs, instructions, and modules stored in the memory 402, thereby implementing the program file encryption method or the program file decryption method in the above method embodiments.

[0085] The memory 402 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created by the processor 401, etc. Furthermore, the memory 402 may include high-speed random access memory and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, the memory 402 may optionally include memory remotely located relative to the processor 401, and these remote memories may be connected to the processor 401 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0086] The one or more modules are stored in the memory 402, and when executed by the processor 401, they perform actions such as... Figure 1 The program file encryption method in the illustrated embodiment, or the execution of such... Figure 2 The program file decryption method in the illustrated embodiment.

[0087] For specific details regarding the aforementioned electronic devices, please refer to the relevant documentation. Figure 1 or Figure 2 The relevant descriptions and effects in the illustrated embodiments are for understanding purposes only and will not be repeated here.

[0088] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), random access memory (RAM), flash memory, hard disk drive (HDD), or solid-state drive (SSD), etc.; the storage medium can also include combinations of the above types of memory.

[0089] Although embodiments of the invention have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the invention, and such modifications and variations all fall within the scope defined by the appended claims.

Claims

1. A method for encrypting program files, characterized in that, include: Obtain the target program to be encrypted, the encryption configuration file, and the license application information corresponding to the target program from the program package to be encrypted; The encryption method of the target program is determined according to the encryption configuration file, and the encryption method includes local encryption and remote encryption; Depending on the encryption method, corresponding target data is sent to the certification center, so that the certification center generates the license information corresponding to the target program and the keys required for encryption and decryption based on the target data. The target data includes license application information. Receive the key corresponding to the target program returned by the authentication center; Obtain a first encrypted file containing the encrypted target program and a second encrypted file containing the corresponding license information; Generate a corresponding decryption program based on the first encrypted file and the second encrypted file; Generate the class library file corresponding to the decryption program and the probe program corresponding to the class library file according to the preset method; Associate the first encrypted file, the second encrypted file, the library file, and the probe program.

2. The method according to claim 1, characterized in that, The step of sending corresponding target data to the certification center based on different encryption methods, so that the certification center generates license information corresponding to the target program and the keys required for encryption and decryption based on the target data, includes: When the target program uses local encryption, it sends a license application to the certification center, so that the certification center generates the license information corresponding to the target program and the keys required for local encryption and decryption based on the license application information. The step of obtaining a first encrypted file containing the encrypted target program and a second encrypted file containing the corresponding license information includes: The target program is encrypted using the key to obtain a first encrypted file; The license information is encrypted using the key to obtain a second encrypted file.

3. The method according to claim 1, characterized in that, The step of sending corresponding target data to the certification center based on different encryption methods, so that the certification center generates license information corresponding to the target program and the keys required for encryption and decryption based on the target data, includes: When the encryption method of the target program is remote encryption, the license application information and the target program are sent to the certification center, so that the certification center generates license information corresponding to the target program according to the license application information, and encrypts the target program with the key to obtain a first encrypted file, and encrypts the license information with the key to obtain a second encrypted file; The step of obtaining a first encrypted file containing the encrypted target program and a second encrypted file containing the corresponding license information includes: Receive the first encrypted file and the second encrypted file returned by the authentication center.

4. The method according to claim 1, characterized in that, After obtaining the first encrypted file containing the encrypted target program and the second encrypted file containing the corresponding license information, the method further includes: The first encrypted file is used to replace the target program in the encrypted program package containing the target program.

5. The method according to claim 1, characterized in that, After generating the library file corresponding to the decryption program and the probe program corresponding to the library file according to the preset method, the method further includes: The library files are then hardened.

6. The method according to claim 1, characterized in that, The method further includes: When a new license application is received for the target program, the new license application is sent to the certification center. When the certification center determines that the usage period included in the new license application has been extended and the new license application meets the renewal conditions, it regenerates the license information corresponding to the target program.

7. A method for decrypting program files, characterized in that, include: When a running request of the target program corresponding to the file to be decrypted is detected, the probe program corresponding to the file to be decrypted is controlled to start running, and the file to be decrypted is obtained by the program file encryption method as described in any one of claims 1-6; The corresponding library file is loaded according to the probe program corresponding to the file to be decrypted, and the file to be decrypted is decrypted.

8. The method according to claim 7, characterized in that, The corresponding library file is loaded according to the probe program corresponding to the file to be decrypted, and the file to be decrypted is decrypted, including: The library file is used to decrypt the license information corresponding to the file to be decrypted, resulting in a first decrypted file; Determine whether the license of the file to be decrypted is within the authentication-free period based on the first decrypted file; If the license of the file to be decrypted is within the authentication-free period, then the decryption operation on the file to be decrypted will be performed.

9. The method according to claim 8, characterized in that, After determining whether the license of the file to be decrypted is within the authentication-free period based on the first decrypted file, the method further includes: If the license of the file to be decrypted is not within the certification-free period, the certification center is requested to verify the license information of the file to be decrypted. Receive the verification result returned by the certification center; If the verification result indicates that the license of the file to be decrypted has not expired, the license information of the file to be decrypted is updated, and the decryption operation of the file to be decrypted is performed.

10. A program file encryption device, characterized in that, include: The first acquisition module is used to acquire the target program to be encrypted, the encryption configuration file, and the license application information corresponding to the target program in the program package to be encrypted. The first determining module is used to determine the encryption method of the target program according to the encryption configuration file, wherein the encryption method includes local encryption and remote encryption; The first sending module is used to send corresponding target data to the certification center according to different encryption methods, so that the certification center generates license information corresponding to the target program and keys required for encryption and decryption based on the target data. The target data includes license application information. A receiving module is used to receive the key corresponding to the target program returned by the authentication center; The second acquisition module is used to acquire a first encrypted file containing the encrypted target program and a second encrypted file containing the corresponding license information. The second determining module is used to generate a corresponding decryption program based on the first encrypted file and the second encrypted file; The third determining module is used to generate a class library file corresponding to the decryption program and a probe program corresponding to the class library file according to a preset method. The association module is used to associate the first encrypted file, the second encrypted file, the class library file, and the probe program.

11. A program file decryption device, characterized in that, include: The calling module is used to control the probe program corresponding to the file to be decrypted to start running when a running request of the target program corresponding to the file to be decrypted is detected. The file to be decrypted is obtained by the program file encryption method as described in any one of claims 1-6. The decryption module is used to load the corresponding class library file according to the probe program corresponding to the file to be decrypted, and to decrypt the file to be decrypted.

12. An electronic device, characterized in that, include: At least one processor; The at least one processor is also connected in communication with a memory, wherein the memory stores instructions that can be executed by the at least one processor to cause the at least one processor to perform the steps of the program file encryption method as described in any one of claims 1-6, or to perform the steps of the program file decryption method as described in any one of claims 7-9.

13. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the program file encryption method as described in any one of claims 1-6, or the steps of the program file decryption method as described in any one of claims 7-9.