Data encryption method, equipment and medium

Through Java reflection technology, the encryption algorithm and management key dynamic selection is solved, and the traditional data encryption method is insufficient flexibility and low security in software development is achieved, efficient and secure data encryption processing is achieved, and the maintenance of the code is improved. sex.

CN119203176APending Publication Date: 2024-12-27INSPUR ZHUOSHU BIG DATA IND DEV CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411229272.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-03
Publication Date
2024-12-27

AI Technical Summary

Technical Problem

Traditional data encryption methods are difficult to meet the needs of strong security, high efficiency and easy management in software development, especially due to insufficient flexibility and security risks caused by hard-coded keys and encryption algorithms.

Method used

Java reflection technology is used to dynamically load and call encryption algorithms, dynamically generate encryption keys, and select appropriate encryption algorithms and management keys according to the needs of the data to be encrypted to realize data encryption processing.

Benefits of technology

It improves the security and efficiency of data encryption, enhances the maintainability and flexibility of code, and resists various attack methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119203176A_ABST
    Figure CN119203176A_ABST
Patent Text Reader

Abstract

The invention discloses a data encryption method, equipment and a medium, belongs to the technical field of data encryption and software development, and is used for solving the technical problems of low data security and low code maintainability of the existing data encryption method. The method comprises the following steps: acquiring an encryption demand of to-be-encrypted data, and determining a specified encryption algorithm used for encrypting the to-be-encrypted data according to the encryption demand; dynamically loading and calling the specified encryption algorithm through a Java reflection technology; dynamically generating an encryption key through a Java reflection technology; and according to the encryption key, performing encryption processing on the to-be-encrypted data through the specified encryption algorithm. According to the method, the security and efficiency of data encryption can be improved, and the maintainability of codes is also remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data encryption and software development, and in particular to a data encryption method, device and medium. Background Art

[0002] With the rapid development of information technology, a large amount of data is transmitted and stored in the network, including personal privacy information, commercial confidential information, etc. In order to protect these important data from being obtained and used by unauthorized persons, data encryption technology has become increasingly important.

[0003] Data encryption is to operate the original data through a certain algorithm so that the content of the data cannot be identified and understood without authorization. Common encryption algorithms include DES, AES, RSA, etc. In the field of modern information technology, data encryption has become a basic means of protecting data security.

[0004] However, with the continuous advancement of computer technology, traditional data encryption methods can no longer meet the needs of the new situation. Strong security, high efficiency and easy management have become the goals of modern data encryption technology. In the process of software development, encryption of sensitive data is particularly important to prevent data leakage and unauthorized access, but traditional encryption processing methods usually require hard coding of keys and encryption algorithms in the code, which is not only inflexible, but also prone to security risks, reducing data security and code maintainability. Summary of the invention

[0005] The present invention provides a data encryption method, device and medium, which are used to solve at least one of the above technical problems.

[0006] The present invention adopts the following technical solutions:

[0007] In a first aspect, the present invention provides a data encryption method, the method comprising: obtaining encryption requirements for data to be encrypted, and determining a specified encryption algorithm to be used when encrypting the data to be encrypted based on the encryption requirements; dynamically loading and calling the specified encryption algorithm through Java reflection technology; dynamically generating an encryption key through Java reflection technology; and encrypting the data to be encrypted based on the encryption key through the specified encryption algorithm.

[0008] In a possible implementation of the present invention, obtaining the encryption requirements of the data to be encrypted includes: obtaining the data type and data encryption level corresponding to the data to be encrypted, wherein the data encryption level is determined according to the sensitivity of the data to be encrypted; and determining the specified encryption algorithm according to the data type and the data encryption level.

[0009] In a possible implementation of the present invention, the specified encryption algorithm includes at least a symmetric encryption algorithm and an asymmetric encryption algorithm; the specified encryption algorithm also includes at least one of a DES encryption algorithm, an AES encryption algorithm and an RSA encryption algorithm.

[0010] In a possible implementation of the present invention, the dynamically loading and calling the specified encryption algorithm through Java reflection technology includes: obtaining encryption parameters required for encrypting the data to be encrypted, the encryption parameters at least including a tool class and parameter information for implementing the specified encryption algorithm; obtaining the encryption parameters using Java reflection technology, and parsing the obtained encryption parameters; and dynamically calling the specified encryption algorithm through the Java reflection technology based on the parsed encryption parameters.

[0011] In a possible implementation of the present invention, before dynamically loading and calling the specified encryption algorithm through Java reflection technology, the method further includes: designing and implementing a class and / or interface for dynamically selecting the specified encryption algorithm.

[0012] In a possible implementation of the present invention, the method further includes: dynamically selecting the specified encryption algorithm according to the encryption requirement by using the Java reflection technology through the class and / or interface.

[0013] In a possible implementation of the present invention, before dynamically generating encryption keys through Java reflection technology, the method further includes: designing and implementing classes and / or interfaces for dynamically managing encryption keys, wherein the dynamic management at least includes dynamic generation.

[0014] In one possible implementation of the present invention, after the data to be encrypted is encrypted, the method further includes: developing a data output interface and / or a data storage interface; and outputting and / or storing the encrypted data through the data output interface and / or the data storage interface.

[0015] In a second aspect, the present invention also provides a data encryption device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor so that the at least one processor can execute: obtaining encryption requirements for data to be encrypted, and determining a specified encryption algorithm to be used when encrypting the data to be encrypted based on the encryption requirements; dynamically loading and calling the specified encryption algorithm through Java reflection technology; dynamically generating an encryption key through Java reflection technology; and encrypting the data to be encrypted through the specified encryption algorithm based on the encryption key.

[0016] In a third aspect, the present invention also provides a non-volatile computer storage medium having computer executable instructions stored thereon, wherein the computer executable instructions are configured to execute: obtaining encryption requirements for data to be encrypted, and determining a specified encryption algorithm to be used when encrypting the data to be encrypted based on the encryption requirements; dynamically loading and calling the specified encryption algorithm through Java reflection technology; dynamically generating an encryption key through Java reflection technology; and encrypting the data to be encrypted through the specified encryption algorithm based on the encryption key.

[0017] The present invention provides a data encryption method, device and medium, which have the following beneficial effects:

[0018] The present invention uses Java reflection technology to dynamically select encryption algorithms and dynamically manage encryption keys, which can not only improve the security of data encryption and resist various attack methods, but also improve the efficiency and response speed of data encryption; at the same time, dynamically selecting encryption algorithms and dynamically managing encryption keys according to the encryption requirements of the data to be encrypted also improves the applicability and flexibility of the data encryption method in the present invention, and at the same time significantly improves the maintainability of the code. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings described below are only some embodiments recorded in the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. In the drawings:

[0020] Figure 1 A flow chart of a data encryption method provided by the present invention;

[0021] Figure 2 A structural schematic diagram of a data encryption device provided by the present invention. DETAILED DESCRIPTION

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

[0023] In order to solve the technical problems of low data encryption security and poor code maintainability caused by the limitations of traditional data encryption methods, the present invention proposes a data encryption method, device and medium. The method is implemented based on Java reflection technology, which can improve the security and efficiency of data encryption to a certain extent, realize efficient encryption and decryption of sensitive data, and the code is highly maintainable, flexible and scalable in application, and can be widely used in various software systems that need to protect data security.

[0024] The method of the present invention is described in detail below with reference to the accompanying drawings.

[0025] Figure 1 A data encryption method flow chart provided by the present invention is as follows: Figure 1 As shown, the data encryption method in the present invention at least includes the following execution steps:

[0026] Step 101: Obtain encryption requirements for data to be encrypted, and determine a specified encryption algorithm to be used when encrypting the data to be encrypted according to the encryption requirements.

[0027] Data to be encrypted refers to data that needs to be encrypted for transmission or encrypted for storage. When encrypting, the encryption requirements of the data to be encrypted must be obtained first. The encryption requirements include the data type and encryption level of the data to be encrypted. The data type refers to the type of data to be encrypted, which determines the adaptive encryption algorithm or encryption method to be used in subsequent encryption. The encryption level of the data is determined according to the security level of the data to be encrypted. The higher the security or sensitivity of the data, or the higher the authority to view and use the data, the higher the encryption level of the data to be encrypted, the more difficult it is to decrypt after encryption, and the less likely it is to be obtained by other personnel. Conversely, if the security or sensitivity of the data is low, the right to use or view the data to be encrypted is low, and accordingly, the encryption level of the data to be encrypted is low.

[0028] Furthermore, after determining the data type and data encryption level corresponding to the data to be encrypted, the encryption algorithm to be used when encrypting the data to be encrypted can be determined based on these two contents, that is, the specified encryption algorithm, where the encryption algorithms here are divided into two categories: symmetric encryption algorithms and asymmetric encryption algorithms, including at least one of the DES encryption algorithm, AES encryption algorithm and RSA encryption algorithm.

[0029] It should be noted that during the encryption process of the data to be encrypted, one encryption algorithm can be used alone, or two or more encryption algorithms can be used in combination at the same time. That is, the number of specified encryption algorithms is not limited and can be adjusted according to the actual encryption process or encryption requirements.

[0030] Step 102: Dynamically load and call the specified encryption algorithm through Java reflection technology.

[0031] After determining the specified encryption algorithm to be used when encrypting the data to be encrypted, the specified encryption algorithm can be dynamically loaded and called through Java reflection technology. Java reflection technology allows the properties of classes and objects to be dynamically checked and operated on when the program or software is running, so the dynamic selection and calling of encryption algorithms can be realized.

[0032] In one possible implementation of the present invention, before using Java reflection technology to dynamically call the aforementioned specified encryption algorithm, it is first necessary to design and implement a class and / or interface that dynamically selects the specified encryption algorithm, and implements the calling of the specified encryption algorithm through these classes and / or interfaces. Specifically, Java reflection technology is used to obtain the classes, methods and parameter information required for data encryption processing, including implementing an encryption algorithm tool class, and then parsing the obtained data encryption processing class, method and parameter information, and then dynamically calling the data encryption processing method based on the parsed data encryption processing class, method and parameter information to perform encryption operations on the data to be encrypted.

[0033] Step 103: Dynamically generate an encryption key using Java reflection technology.

[0034] In order to further ensure the security of data encryption, the encryption key can be dynamically managed through Java reflection technology when encrypting the data to be encrypted. The dynamic management process here at least includes dynamically generating encryption keys, but before that, it is also necessary to design and implement classes and / or interfaces for dynamically managing encryption keys before the encryption key management can be realized through these classes and / or interfaces.

[0035] Step 104: Encrypt the data to be encrypted using a specified encryption algorithm according to the encryption key.

[0036] Finally, the data to be encrypted is encrypted according to the dynamically generated encryption key and the dynamically selected encryption algorithm.

[0037] In one possible implementation of the present invention, after the encryption processing of the encrypted data is completed, a data output interface and / or a data storage interface can also be developed, and then the encrypted data can be output and / or stored through these data output interfaces and / or data storage interfaces.

[0038] Furthermore, after the encryption is completed, the feasibility and security of the data encryption method proposed in the present invention can be verified by testing the security of the encrypted data.

[0039] In order to explain the data encryption method in this application in more detail, the present invention also provides the following supplementary description.

[0040] In the Java algorithm, reflection technology can be used to implement data encryption processing. Reflection technology is a powerful function of Java, which allows programs or software to dynamically check the properties of classes and / or objects at runtime and operate them. Through Java reflection technology, data encryption processing can be implemented, and data can be dynamically encrypted and decrypted at runtime. Based on this, a base data encryption method proposed by the present invention can also include the following steps:

[0041] 1)Choice of encryption algorithm

[0042] In the process of data encryption, it is very important to select a suitable encryption algorithm. Usually, DES encryption algorithm, AES encryption algorithm, RSA encryption algorithm, etc. are used for data encryption. In the present invention, a modern encryption algorithm, such as AES encryption algorithm, is used. AES encryption algorithm is a symmetric encryption algorithm with high security, high efficiency and easy implementation. In the process of data encryption, the AES encryption algorithm can be dynamically selected and called through Java reflection technology to improve the flexibility and security of data encryption.

[0043] 2) Dynamically select encryption algorithm

[0044] In the traditional data encryption processing process, the encryption algorithm used is usually fixed and difficult to select flexibly. In order to increase the flexibility of the data encryption processing method in the present invention, a method for dynamically selecting an encryption algorithm through Java reflection technology is proposed. Through Java reflection technology, the specified encryption algorithm can be dynamically loaded and called during the encryption process. In this way, a suitable encryption algorithm can be dynamically selected according to specific encryption requirements without determining the specific algorithm class at compile time, thereby improving the applicability and security of the data encryption processing method.

[0045] 3) Dynamically manage encryption keys

[0046] In the process of data encryption, the management of encryption keys is also very important. In order to increase the security of the data encryption processing method, the present invention proposes a step of dynamically managing encryption keys through Java reflection technology. Through Java reflection technology, encryption keys can be dynamically generated and managed during the data encryption process. In this way, encryption keys can be dynamically updated and managed as needed, thereby improving the security of the data encryption processing method.

[0047] That is, the key to the data encryption method proposed in the present invention lies in the use of Java reflection technology, which can not only realize the dynamic selection of encryption algorithm, so that the encryption algorithm used in the encryption process is more in line with or meets the encryption requirements of the data, thereby improving the security of data encryption, but also realize the dynamic generation and dynamic management of encryption keys, making the key management more flexible, and the dynamically generated keys in each encryption process are not unique and fixed, which also has a positive impact on increasing the security of data encryption. In addition, because Java reflection technology is used, the maintainability of the code is also significantly improved.

[0048] Based on the same inventive concept, the present invention also provides a data encryption device, whose structure is as follows: Figure 2 shown.

[0049] Figure 2 This is a schematic diagram of the structure of a data encryption device provided by the present invention. Figure 2 As shown, the data encryption device 200 in the present invention specifically includes: at least one processor 201; and a memory 203 that is communicatively connected to the at least one processor 201 (connected via a bus 202); wherein the memory 203 stores instructions that can be executed by the at least one processor 201, so that the at least one processor 201 can execute a data encryption method as described in the above embodiment.

[0050] In one possible implementation of the present invention, the aforementioned processor is used to execute, obtain encryption requirements for data to be encrypted, and determine a specified encryption algorithm to be used when encrypting the data to be encrypted based on the encryption requirements; dynamically load and call the specified encryption algorithm through Java reflection technology; dynamically generate an encryption key through Java reflection technology; and encrypt the data to be encrypted through the specified encryption algorithm based on the encryption key.

[0051] In addition, the present invention further provides a non-volatile computer storage medium on which computer executable instructions are stored, and the computer executable instructions are configured to execute a data encryption method as described in the above embodiment.

[0052] In one possible implementation of the present invention, the aforementioned computer executable instructions are configured to execute, obtain encryption requirements for data to be encrypted, and determine a specified encryption algorithm to be used when encrypting the data to be encrypted based on the encryption requirements; dynamically load and call the specified encryption algorithm through Java reflection technology; dynamically generate an encryption key through Java reflection technology; and encrypt the data to be encrypted based on the encryption key through the specified encryption algorithm.

[0053] Each embodiment of the present invention is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the IoT device and medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.

[0054] The system and medium provided by the present invention correspond one-to-one to the method, and therefore, the system and medium also have similar beneficial technical effects to the corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the system and medium will not be repeated here.

[0055] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0056] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0057] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0058] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0059] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0060] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0061] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0062] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0063] The above are only embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A data encryption method, characterized in that: The method comprises: Obtaining encryption requirements for the data to be encrypted, and determining a specified encryption algorithm to be used when encrypting the data to be encrypted according to the encryption requirements; Dynamically load and call the specified encryption algorithm through Java reflection technology; Dynamically generate encryption keys through Java reflection technology; The data to be encrypted is encrypted using the specified encryption algorithm according to the encryption key.

2. A data encryption method according to claim 1, characterized in that: The obtaining of encryption requirements of the data to be encrypted includes: Acquire a data type and a data encryption level corresponding to the data to be encrypted, wherein the data encryption level is determined according to a sensitivity of the data to be encrypted; The designated encryption algorithm is determined according to the data type and the data encryption level.

3. A data encryption method according to claim 2, characterized in that: The specified encryption algorithm includes at least a symmetric encryption algorithm and an asymmetric encryption algorithm; The specified encryption algorithm also includes at least one of a DES encryption algorithm, an AES encryption algorithm, and an RSA encryption algorithm.

4. A data encryption method according to claim 1, characterized in that: The dynamically loading and calling the specified encryption algorithm by Java reflection technology includes: Acquire encryption parameters required for encrypting the data to be encrypted, wherein the encryption parameters at least include a tool class and parameter information for implementing the specified encryption algorithm; Using Java reflection technology to obtain the encryption parameters, and parsing the obtained encryption parameters; According to the parsed encryption parameters, the specified encryption algorithm is dynamically called through the Java reflection technology.

5. A data encryption method according to claim 1, characterized in that: Before dynamically loading and calling the specified encryption algorithm through Java reflection technology, the method further includes: Design and implement classes and / or interfaces that dynamically select the specified encryption algorithm.

6. A data encryption method according to claim 5, characterized in that: The method further comprises: The specified encryption algorithm is dynamically selected by using the Java reflection technology according to the encryption requirements through the class and / or interface.

7. A data encryption method according to claim 1, characterized in that: Before dynamically generating the encryption key by using the Java reflection technology, the method further includes: Design and implement classes and / or interfaces for dynamic management of encryption keys, where the dynamic management includes at least dynamic generation.

8. A data encryption method according to claim 1, characterized in that: After encrypting the data to be encrypted, the method further includes: Develop data output interfaces and / or data storage interfaces; The encrypted data is output and / or stored via the data output interface and / or the data storage interface.

9. A data encryption device, characterized in that: The device comprises: 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 to enable the at least one processor to: Obtaining encryption requirements for the data to be encrypted, and determining a specified encryption algorithm to be used when encrypting the data to be encrypted according to the encryption requirements; Dynamically load and call the specified encryption algorithm through Java reflection technology; Dynamically generate encryption keys through Java reflection technology; The data to be encrypted is encrypted using the specified encryption algorithm according to the encryption key.

10. A non-volatile computer storage medium having computer executable instructions stored thereon, characterized in that: The computer executable instructions are configured to perform: Obtaining encryption requirements for the data to be encrypted, and determining a specified encryption algorithm to be used when encrypting the data to be encrypted according to the encryption requirements; Dynamically load and call the specified encryption algorithm through Java reflection technology; Dynamically generate encryption keys through Java reflection technology; The data to be encrypted is encrypted using the specified encryption algorithm according to the encryption key.