Model-driven database encryption storage method and system
Through the model-driven database encryption method, sensitive information is encrypted and decrypted using configuration files and encryption tools, solving the problems of management complexity and performance overhead in the existing technology, and achieving efficient sensitive information protection and security guarantee.
Patent Information
- Application Number
- CN202411253768.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-09
- Publication Date
- 2024-12-27
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
When existing database encryption technologies balance security and performance, management complexity and performance overhead are high, and it is difficult to scale and adjust, especially in the encrypted storage and decryption of sensitive information.
Using a model-driven database encryption storage method, the configuration manager for sensitive fields is defined, the encryption and decryption tools are used to encrypt and decrypt sensitive information, and the incoming and outgoing parameters are intercepted through the data access layer interceptor, using reflection technology Read and write back sensitive field content, encrypt and decrypt using Unicode code dot separators and hexadecimal obfuscation algorithm.
It improves the efficiency of matching and acquisition of sensitive fields, ensures data security, and saves R&D costs. There is no additional key management during the encryption and decryption process, maintaining the data inclusion relationship.
Smart Images

Figure CN119203183A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of IT and software development, and in particular to a model-driven database encryption storage method and a model-driven database encryption storage system. Background Art
[0002] With the continuous development of information technology, network security is increasingly valued by people, and data security has become a top priority and a core issue in the information age. Among the many data security measures, simply displaying data without sensitization can no longer meet the requirements of many industry regulations and corporate management systems. Encrypted storage of sensitive information in the database has become a key technical means to ensure the security of static data in the database, thereby protecting personal privacy and corporate information security.
[0003] The technical indicators involved in data encryption mainly include the selection of encryption algorithms, the formulation of encryption strategies, key management, and encryption and decryption performance.
[0004] Although the database-level encryption technology of TDE (Transparent Data Encryption) can simplify encryption management, its query performance is poor; row-level encryption has certain flexibility, but its management complexity and performance overhead are still very high. Therefore, in order to balance security and performance, column-level encryption is generally used, which only encrypts specific sensitive columns, such as passwords, ID numbers, mobile phone numbers, etc., while other columns remain in plain text. However, when implementing encryption, many database systems require hard coding to encrypt and store specific database fields and decrypt and read them, which is not easy to expand and adjust. Summary of the invention
[0005] In order to solve the above technical problems, the present invention provides a model-driven database encryption storage method and system, which can not only improve the efficiency of sensitive field matching and acquisition, but also ensure the security of data, while saving R&D costs.
[0006] The technical solution adopted by the present invention is as follows:
[0007] A model-driven database encryption storage method comprises the following steps: defining a configuration file, and specifying the name, content format and specification of the configuration file, wherein the content of the configuration file is the fully qualified name and attribute fields of a data table model entity class of sensitive information; creating a sensitive field configuration manager, and loading the configuration file through the sensitive field configuration manager to obtain sensitive information model entities and attribute fields; creating an encryption and decryption tool for sensitive information, and encrypting and decrypting the sensitive information through the encryption and decryption tool; creating a data access layer interceptor, and intercepting the input and output parameters of DAO (Data Access Objects) data access through the data access layer interceptor; identifying sensitive attribute fields in the input and output parameters through the sensitive field configuration manager, and reading the content of the sensitive attribute fields through reflection technology; encrypting the sensitive fields in the input parameters and decrypting the sensitive attribute fields in the output parameters through the encryption and decryption tool, and writing back the encrypted and decrypted sensitive attribute field contents through the reflection technology.
[0008] In one embodiment of the present invention, the encryption of sensitive data by the encryption tool specifically includes: defining a Unicode code point separator, wherein the Unicode code point separator is used to separate the ciphertext corresponding to each character in the original string; establishing a hexadecimal obfuscation algorithm; looping through and converting each of the characters in the sensitive data string to be encrypted into a corresponding hexadecimal code point, and obfuscating the hexadecimal Unicode code point corresponding to each character one by one by using the hexadecimal obfuscation algorithm; and concatenating the obfuscated hexadecimal code points into a new string by using the Unicode code point separator and returning it as ciphertext.
[0009] In one embodiment of the present invention, the decryption of the sensitive information by the decryption tool specifically includes: splitting the ciphertext field into an array by the Unicode code point separator and traversing it in a loop; converting the hexadecimal code points back to character types one by one by an obfuscation restoration algorithm and splicing them into a result string.
[0010] In one embodiment of the present invention, the obfuscation algorithm and the obfuscation restoration algorithm perform an XOR bitwise operation based on the ASCII value of each character.
[0011] In one embodiment of the present invention, two character strings in a containment relationship still maintain the original containment relationship after being encrypted and decrypted, and there is no additional key distribution management during the encryption and decryption process.
[0012] A model-driven database encryption storage system comprises: a definition module, the definition module is used to define a configuration file, and to specify the name, content format and specification of the configuration file, wherein the content of the configuration file is the fully qualified name of a data table model entity class and attribute fields of sensitive information; an acquisition module, the acquisition module is used to create a sensitive field configuration manager, and to load the configuration file through the sensitive field configuration manager to obtain sensitive information model entities and attribute fields; an encryption and decryption module, the encryption and decryption module is used to create an encryption and decryption tool for sensitive information, and to encrypt and decrypt the sensitive information through the encryption and decryption tool; an interception module, the interception module is used to create a data access layer interceptor, and to intercept the input and output parameters of DAO data access through the data access layer interceptor; a reading module, the reading module is used to identify the sensitive attribute fields in the input and output parameters through the sensitive field configuration manager, and to read the content of the sensitive attribute fields through reflection technology; a write-back module, the write-back module is used to encrypt the sensitive fields in the input parameters and decrypt the sensitive attribute fields in the output parameters through the encryption and decryption tools, and to write back the encrypted and decrypted sensitive attribute field contents through the reflection technology.
[0013] In one embodiment of the present invention, the encryption and decryption module is also used to: define a Unicode code point separator, which is used to separate the ciphertext corresponding to each character in the original string; establish a hexadecimal obfuscation algorithm; loop through each of the characters in the sensitive data string to be encrypted to convert it into a corresponding hexadecimal code point, and use the hexadecimal obfuscation algorithm to obfuscate the hexadecimal Unicode code point corresponding to each character one by one; and splice the obfuscated hexadecimal code points into a new string through the Unicode code point separator and return it as ciphertext.
[0014] In one embodiment of the present invention, the encryption and decryption module is also used to: split the ciphertext field into an array by the Unicode code point separator and traverse it in a loop; convert the hexadecimal code points back to character type one by one by an obfuscation restoration algorithm and splice them into a result string.
[0015] In one embodiment of the present invention, the obfuscation algorithm and the obfuscation restoration algorithm perform an XOR bitwise operation based on the ASCII value of each character.
[0016] In one embodiment of the present invention, two character strings in a containment relationship still maintain the original containment relationship after being encrypted and decrypted, and there is no additional key distribution management during the encryption and decryption process.
[0017] Beneficial effects of the present invention:
[0018] The present invention defines a configuration file and specifies the name, content format and specification of the configuration file, then creates a sensitive field configuration manager, and loads the configuration file to obtain sensitive information model entities and attribute fields, then creates an encryption and decryption tool for sensitive information, and encrypts and decrypts the sensitive information, then intercepts the input and output parameters of DAO data access by obtaining a data access layer interceptor, and identifies the sensitive attribute fields in the input and output parameters through the sensitive field configuration manager, and reads the content of the sensitive attribute field through the reflection technology, finally encrypts the sensitive fields in the input parameters and decrypts the sensitive attribute fields in the output parameters through the encryption and decryption tool, and writes back the encrypted and decrypted sensitive attribute field content through the reflection technology, thereby not only improving the efficiency of sensitive field matching and acquisition, but also ensuring data security, while saving research and development costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 A flowchart of a model-driven database encryption storage method according to an embodiment of the present invention;
[0020] Figure 2 The present invention is a block diagram of a model-driven database encryption storage system according to an embodiment of the present invention. DETAILED DESCRIPTION
[0021] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of 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 the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0022] Figure 1 The present invention is a flowchart of a model-driven database encryption storage method according to an embodiment of the present invention.
[0023] like Figure 1 As shown, the model-driven database encryption storage method of the embodiment of the present invention includes the following steps:
[0024] S1, define the configuration file and specify the name, content format and specifications of the configuration file. The content of the configuration file is the fully qualified name and attribute fields of the data table model entity class of sensitive information.
[0025] Specifically, a sensitive field configuration file "sensitiveProp.xml" in XML format can be created under the code project of the application system, where under the XML root node is a two-layer nested array structure. The outer array node of the array structure can be a data table model entity, and the node can be named domain, containing the attribute class, and the class attribute value can be the unique fully qualified name of the data table model entity class where the sensitive information field exists. Under the domain node is an inner array of sensitive attribute fields contained in the model entity, and the attribute field node is named field. The node value is the attribute name of the sensitive field defined by the model entity class, including the attribute label, and the label attribute value is the Chinese description of the field. It can be understood that a domain array can be defined through XML, and each domain object has a field array data structure inside.
[0026] S2, create a sensitive field configuration manager, and load the configuration file through the sensitive field configuration manager to obtain sensitive information model entities and attribute fields.
[0027] In one embodiment of the present invention, a sensitive field configuration manager may be provided to load configuration files, and local cache technology may be combined to centrally manage configuration items, thereby providing writing and searching capabilities.
[0028] Specifically, first, you can create a sensitive field configuration manager class named "SensitivePropManager.java", in which you can agree on the reading path of the sensitive field configuration file "sensitiveProp.xml" under the code project of the application system. Then, you can define a Map<String,List> The global static variable cache of the structure is used as a local cache to save the parsed data of "sensitiveProp.xml". Among them, the Map of the global static variable cache<K,V> The K key in the structure stores the class attribute value of each domain node, and the corresponding V value stores the field node array. Secondly, more importantly, the class must provide a load method for loading the sensitive field configuration file, which is responsible for loading and parsing the "sensitiveProp.xml" configuration file, so that the sensitive field configuration can be read into the class's global static variable cache. Finally, a method can be provided to determine whether it is a sensitive information model entity class based on the fully qualified name of the Java entity class, that is, the configured sensitive information model entity class exists in the global static variable cache, and a method is provided to obtain the corresponding sensitive field list from the global static variable cache based on the fully qualified name of the Java entity class.
[0029] S3, create encryption and decryption tools for sensitive information, and encrypt and decrypt sensitive information through encryption and decryption tools.
[0030] In one embodiment of the present invention, two character strings in a containment relationship still maintain the original containment relationship after being encrypted and decrypted, and there is no additional key distribution management during the encryption and decryption process.
[0031] In one embodiment of the present invention, encrypting sensitive data by using an encryption tool may specifically include: defining a Unicode code point separator, the Unicode code point separator is used to separate the ciphertext corresponding to each character in the original string; establishing a hexadecimal obfuscation algorithm; looping through and converting each character in the sensitive data string to be encrypted into a corresponding hexadecimal code point, and obfuscating the hexadecimal Unicode code point corresponding to each character one by one by using the hexadecimal obfuscation algorithm; splicing the obfuscated hexadecimal code points into a new string by using the Unicode code point separator and returning it as ciphertext.
[0032] Specifically, first, you can create a Unicode character encryption and decryption tool class named "UnicodeCharEncryptor.java" as an encryption and decryption tool for sensitive data. The class needs to provide two public methods of encryption and decryption, as well as an optional obfuscation algorithm for increasing the difficulty of encryption and decryption, and a corresponding obfuscation restoration algorithm. Then, you can traverse the char characters of the String string to be encrypted, and convert each character into a hexadecimal Unicode code point through Java's built-in Integer.toHexString(char) method; then use the obfuscation algorithm to obfuscate it. Finally, the obfuscated result string of the Unicode code point converted from each char character in the string can be concatenated with a special connection character to return the ciphertext string. It should be noted that the selected special connection character cannot exist in the character set that the ciphertext string may contain.
[0033] In one embodiment of the present invention, the sensitive information is decrypted by a decryption tool, which may specifically include: splitting the ciphertext field into an array by Unicode code point separators and looping through it; converting the hexadecimal code points back to character types one by one by an obfuscation restoration algorithm and splicing them into a result string.
[0034] Specifically, first, the selected special connection character can be used to separate the string into an array, and each substring in the array can be traversed, where the substring is the obfuscated result of the Unicode code point of the original char character. Then, the obfuscation restoration algorithm can be used to convert the substring back to the Unicode code point, and the Java built-in Integer.parseInt (Unicode code point, 16) can be used to convert it into a decimal representation, and then the char type can be used to force the conversion of the decimal representation of the Unicode code point to a char character, thus achieving the purpose of restoring the original char character. Finally, all the restored original char characters can be concatenated into a string and returned to complete the data decryption.
[0035] In one embodiment of the present invention, the obfuscation algorithm and the obfuscation restoration algorithm may be an XOR bitwise operation based on the ASCII value of each character. The XOR operation is performed once to obtain the obfuscation algorithm, and the obfuscated result is subjected to another XOR operation to obtain the obfuscation restoration algorithm.
[0036] Specifically, first, a hexadecimal Unicode code point string can be received, and each character in it can be traversed, and the ASCII value of the character can be XORed with a fixed value of int type. Then, the char value of the XOR operation result of each character can be concatenated into a new string, that is, the purpose of obfuscating the hexadecimal string is achieved. It should be noted that since the XOR operation method is adopted, the reversibility of the obfuscation is guaranteed.
[0037] Furthermore, since the obfuscation algorithm uses the reversible characteristic of the XOR operation, the obfuscation restoration algorithm only needs to directly call the obfuscation method, that is, the XOR operation result is XORed again to restore it.
[0038] It should be noted that since the ciphertext is encrypted and concatenated character by character, two strings that have a containment relationship will inevitably retain the original containment relationship after encryption.
[0039] S4, create a data access layer interceptor, and intercept the input and output parameters of DAO data access through the data access layer interceptor.
[0040] In one embodiment of the present invention, an interceptor can be created to intercept the call capability of the data access layer, and add pre-parameter processing and post-result processing to the intercepted database read and write methods. Among them, the sensitive field configuration manager can be used to identify the model entity class of sensitive information to obtain the list of sensitive information attribute fields, and then perform traversal processing.
[0041] Specifically, first, the AOP aspect technology of the Spring framework can be used to intercept all database read and write access methods of all data access layer DAO operation objects. Then, the @Around surrounding notification can be used to add pre-operation and post-operation logic before and after the original method. In the pre-operation, the input parameter group is obtained through the AOP entry point, and the sensitive attribute field values of the sensitive information data table model entity class are traversed to encrypt the input parameters; in the post-operation, the sensitive attribute field values of the sensitive information data table model entity class are decrypted and restored.
[0042] S5, identifies the sensitive attribute fields in the input and output parameters through the sensitive field configuration manager, and reads the contents of the sensitive attribute fields through reflection technology.
[0043] In one embodiment of the present invention, reflection technology can be used to first read the content value of the sensitive field, and then an encryption and decryption tool can be used to encrypt the sensitive information attribute field data in the data table model entity in the pre-parameter processing, and then the sensitive information attribute field data can be decrypted in the post-result processing of the query operation, and the encrypted and decrypted data can be written back to overwrite the original sensitive attribute field in combination with reflection technology.
[0044] Specifically, first, for each input parameter and output parameter of the entry point method, the method for determining whether it is a sensitive information model entity class provided in the sensitive field configuration manager "SensitivePropManager.java" provided in step S2 can be called to identify and determine the input parameter and output parameter. If it is a sensitive information model entity class, the method provided in "SensitivePropManager.java" can be called, and the corresponding sensitive attribute field list can be obtained according to the fully qualified name of the parameter entity class, and then the attribute fields are traversed one by one, and each sensitive attribute field value is read through Java reflection technology.
[0045] S6, encrypt the sensitive fields in the input parameters and decrypt the sensitive attribute fields in the output parameters through encryption and decryption tools, and write back the encrypted and decrypted sensitive attribute field contents through reflection technology.
[0046] Specifically, in the internal logic of step S5 implemented by the pre-operation and post-operation codes of the AOP aspect, for each sensitive attribute field traversed, the encryption and decryption tool "UnicodeCharEncryptor.java" provided in step S3 can be used to complete the encryption of the input sensitive field and the decryption of the output sensitive field, respectively, and use Java reflection technology to write the encryption and decryption results back to the model entity.
[0047] Among them, since the encryption and decryption method of the embodiment of the present invention has the characteristic of retaining the inclusion relationship between two original plaintext character strings, it can support field fuzzy query.
[0048] According to the model-driven database encryption storage method of the embodiment of the present invention, a configuration file is defined and the name, content format and specification of the configuration file are specified, and then a sensitive field configuration manager is created, and the configuration file is loaded to obtain sensitive information model entities and attribute fields. Then, an encryption and decryption tool for sensitive information is created, and the sensitive information is encrypted and decrypted. After that, the input and output parameters of DAO data access are intercepted by obtaining a data access layer interceptor, and the sensitive attribute fields in the input and output parameters are identified by the sensitive field configuration manager, and the content of the sensitive attribute fields is read by reflection technology. Finally, the sensitive fields in the input parameters are encrypted and the sensitive attribute fields in the output parameters are decrypted by the encryption and decryption tool, and the encrypted and decrypted sensitive attribute field contents are written back by reflection technology. Therefore, not only the efficiency of sensitive field matching and acquisition can be improved, but also the security of data can be guaranteed, while saving R&D costs.
[0049] In order to implement the model-driven database encryption storage method of the above embodiment, the present invention also proposes a model-driven database encryption storage system.
[0050] like Figure 2 As shown, the model-driven database encryption storage system of the embodiment of the present invention may include: a definition module 100, an acquisition module 200, an encryption and decryption module 300, an interception module 400, a reading module 500 and a write-back module 600, wherein the definition module 100 may be used to define a configuration file, and specify the name, content format and specification of the configuration file, and the content of the configuration file is the fully qualified name and attribute fields of the data table model entity class of the sensitive information; the acquisition module 200 may be used to create a sensitive field configuration manager, and load the configuration file through the sensitive field configuration manager to obtain the sensitive information model entity and attribute fields; the encryption and decryption module 300 0 can be used to create encryption and decryption tools for sensitive information, and encrypt and decrypt sensitive information through the encryption and decryption tools; the interception module 400 can be used to create a data access layer interceptor, and intercept the input and output parameters of DAO data access through the data access layer interceptor; the reading module 500 can be used to identify sensitive attribute fields in the input and output parameters through the sensitive field configuration manager, and read the contents of the sensitive attribute fields through reflection technology; the write-back module 600 can be used to encrypt the sensitive fields in the input parameters and decrypt the sensitive attribute fields in the output parameters through the encryption and decryption tools, and write back the encrypted and decrypted sensitive attribute field contents through reflection technology.
[0051] Specifically, the definition module 100 can create a sensitive field configuration file "sensitiveProp.xml" in XML format under the code engineering of the application system, wherein under the XML root node is a two-layer nested array structure. The outer array node of the array structure can be a data table model entity, and the node can be named domain, containing the attribute class, and the class attribute value can be the unique fully qualified name of the data table model entity class where the sensitive information field exists. Under the domain node is an inner array of sensitive attribute fields contained in the model entity, and the attribute field node is named field, and the node value is the attribute name of the sensitive field defined by the model entity class, containing the attribute label, and the label attribute value is the Chinese description of the field. It can be understood that a domain array can be defined through XML, and each domain object has a data structure of a field array inside.
[0052] In one embodiment of the present invention, the acquisition module 200 may load configuration files by providing a sensitive field configuration manager, and centrally manage configuration items in combination with local cache technology, thereby providing write and search capabilities.
[0053] Specifically, first, you can create a sensitive field configuration manager class named "SensitivePropManager.java", in which you can agree on the reading path of the sensitive field configuration file "sensitiveProp.xml" under the code project of the application system. Then, you can define a Map<String,List> The global static variable cache of the structure is used as a local cache to save the parsed data of "sensitiveProp.xml". Among them, the Map of the global static variable cache<K,V> The K key in the structure stores the class attribute value of each domain node, and the corresponding V value stores the field node array. Secondly, more importantly, the class must provide a load method for loading the sensitive field configuration file, which is responsible for loading and parsing the "sensitiveProp.xml" configuration file, so that the sensitive field configuration can be read into the class's global static variable cache. Finally, a method can be provided to determine whether it is a sensitive information model entity class based on the fully qualified name of the Java entity class, that is, the configured sensitive information model entity class exists in the global static variable cache, and a method is provided to obtain the corresponding sensitive field list from the global static variable cache based on the fully qualified name of the Java entity class.
[0054] In one embodiment of the present invention, two character strings in a containment relationship still maintain the original containment relationship after being encrypted and decrypted, and there is no additional key distribution management during the encryption and decryption process.
[0055] In one embodiment of the present invention, the encryption / decryption module 300 can also be used to: define a Unicode code point separator, which is used to separate the ciphertext corresponding to each character in the original string; establish a hexadecimal obfuscation algorithm; loop through each character in the sensitive data string to be encrypted to convert it into a corresponding hexadecimal code point, and obfuscate the hexadecimal Unicode code point corresponding to each character one by one through the hexadecimal obfuscation algorithm; splice the obfuscated hexadecimal code points into a new string through the Unicode code point separator and return it as ciphertext.
[0056] Specifically, first, you can create a Unicode character encryption and decryption tool class named "UnicodeCharEncryptor.java" as an encryption and decryption tool for sensitive data. The class needs to provide two public methods of encryption and decryption, as well as an optional obfuscation algorithm for increasing the difficulty of encryption and decryption, and a corresponding obfuscation restoration algorithm. Then, you can traverse the char characters of the String string to be encrypted, and convert each character into a hexadecimal Unicode code point through Java's built-in Integer.toHexString(char) method; then use the obfuscation algorithm to obfuscate it. Finally, the obfuscated result string of the Unicode code point converted from each char character in the string can be concatenated with a special connection character to return the ciphertext string. It should be noted that the selected special connection character cannot exist in the character set that the ciphertext string may contain.
[0057] In one embodiment of the present invention, the encryption and decryption module 300 can also be used to: split the ciphertext field into an array by Unicode code point separators and traverse it in a loop; convert the hexadecimal code points back to character type one by one by using an obfuscation restoration algorithm and splice them into a result string.
[0058] Specifically, first, the selected special connection character can be used to separate the string into an array, and each substring in the array can be traversed, where the substring is the obfuscated result of the Unicode code point of the original char character. Then, the obfuscation restoration algorithm can be used to convert the substring back to the Unicode code point, and the Java built-in Integer.parseInt (Unicode code point, 16) can be used to convert it into a decimal representation, and then the char type can be used to force the conversion of the decimal representation of the Unicode code point to a char character, thus achieving the purpose of restoring the original char character. Finally, all the restored original char characters can be concatenated into a string and returned to complete the data decryption.
[0059] In one embodiment of the present invention, the obfuscation algorithm and the obfuscation restoration algorithm may be an XOR bitwise operation based on the ASCII value of each character. The XOR operation is performed once to obtain the obfuscation algorithm, and the obfuscated result is subjected to another XOR operation to obtain the obfuscation restoration algorithm.
[0060] Specifically, first, a hexadecimal Unicode code point string can be received, and each character in it can be traversed, and the ASCII value of the character can be XORed with a fixed value of int type. Then, the char value of the XOR operation result of each character can be concatenated into a new string, that is, the purpose of obfuscating the hexadecimal string is achieved. It should be noted that since the XOR operation method is adopted, the reversibility of the obfuscation is guaranteed.
[0061] Furthermore, since the obfuscation algorithm uses the reversible characteristic of the XOR operation, the obfuscation restoration algorithm only needs to directly call the obfuscation method, that is, the XOR operation result is XORed again to restore it.
[0062] It should be noted that since the ciphertext is encrypted and concatenated character by character, two strings that have a containment relationship will inevitably retain the original containment relationship after encryption.
[0063] In one embodiment of the present invention, an interceptor can be created through the interception module 400 to intercept the call capability of the data access layer, and add pre-parameter processing and post-result processing to the intercepted database read and write methods. Among them, the sensitive field configuration manager can be used to identify the model entity class of sensitive information to obtain the list of sensitive information attribute fields, and then perform traversal processing.
[0064] Specifically, first, the AOP aspect technology of the Spring framework can be used to intercept all database read and write access methods of all data access layer DAO operation objects. Then, the @Around surrounding notification can be used to add pre-operation and post-operation logic before and after the original method. In the pre-operation, the input parameter group is obtained through the AOP entry point, and the sensitive attribute field values of the sensitive information data table model entity class are traversed to encrypt the input parameters; in the post-operation, the sensitive attribute field values of the sensitive information data table model entity class are decrypted and restored.
[0065] In one embodiment of the present invention, the reading module 500 may first use reflection technology to read the content value of the sensitive field, and then use the encryption and decryption tool to encrypt the sensitive information attribute field data in the data table model entity in the pre-parameter processing, and then decrypt the sensitive information attribute field data in the post-result processing of the query operation, and combine the reflection technology to realize the encrypted and decrypted data write back to overwrite the original sensitive attribute field.
[0066] Specifically, first, for each input parameter and output parameter of the entry point method, the method for determining whether it is a sensitive information model entity class provided in the sensitive field configuration manager "SensitivePropManager.java" provided in step S2 can be called to identify and determine the input parameter and output parameter. If it is a sensitive information model entity class, the method provided in "SensitivePropManager.java" can be called, and the corresponding sensitive attribute field list can be obtained according to the fully qualified name of the parameter entity class, and then the attribute fields are traversed one by one, and each sensitive attribute field value is read through Java reflection technology.
[0067] In one embodiment of the present invention, in the internal logic of step S5 implemented by the pre-operation and post-operation code of the AOP aspect through the write-back module 600, for each sensitive attribute field traversed, the encryption and decryption tool "UnicodeCharEncryptor.java" provided in step S3 can be used to complete the encryption of the input sensitive field and the decryption of the output sensitive field respectively, and the encryption and decryption results can be written back to the model entity using Java reflection technology.
[0068] Among them, since the encryption and decryption method of the embodiment of the present invention has the characteristic of retaining the inclusion relationship between two original plaintext character strings, it can support field fuzzy query.
[0069] To summarize, the present invention obtains the configuration file through the definition module and specifies the name, content format and specification of the configuration file, then creates a sensitive field configuration manager, and loads the configuration file through the acquisition module to obtain the sensitive information model entity and attribute field, and then creates an encryption and decryption tool for sensitive information through the encryption and decryption module, and encrypts and decrypts the sensitive information, and then obtains the data access layer interceptor through the interception module to intercept the input and output parameters of the DAO data access, and identifies the sensitive attribute fields in the input and output parameters through the sensitive field configuration manager, and reads the content of the sensitive attribute field through the reading module, and finally writes back the encrypted and decrypted sensitive attribute field content through the write-back module, thereby not only improving the efficiency of sensitive field matching and acquisition, but also ensuring data security, while saving research and development costs.
[0070] In the description of the present invention, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. "Multiple" means two or more, unless otherwise clearly and specifically defined.
[0071] In the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", "connected", "fixed" and the like should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0072] In the present invention, unless otherwise clearly specified and limited, a first feature being "above" or "below" a second feature may mean that the first and second features are in direct contact, or the first and second features are in indirect contact through an intermediate medium. Moreover, a first feature being "above", "above" or "above" a second feature may mean that the first feature is directly above or obliquely above the second feature, or simply means that the first feature is higher in level than the second feature. A first feature being "below", "below" or "below" a second feature may mean that the first feature is directly below or obliquely below the second feature, or simply means that the first feature is lower in level than the second feature.
[0073] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, unless they are contradictory.
[0074] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present invention includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by those skilled in the art to which the embodiments of the present invention belong.
[0075] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purposes of this specification, a "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic devices), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways if necessary, and then stored in a computer memory.
[0076] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0077] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0078] In addition, each functional unit in each embodiment of the present invention may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0079] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.
Claims
1. A model-driven database encryption storage method, characterized in that: The following steps are involved: Define a configuration file, and specify the name, content format and specification of the configuration file, wherein the content of the configuration file is the fully qualified name and attribute fields of the data table model entity class of sensitive information; Creating a sensitive field configuration manager, and loading the configuration file through the sensitive field configuration manager to obtain sensitive information model entities and attribute fields; Creating an encryption and decryption tool for sensitive information, and encrypting and decrypting the sensitive information using the encryption and decryption tool; Create a data access layer interceptor, and intercept the input and output parameters of DAO data access through the data access layer interceptor; Identify sensitive attribute fields in input parameters and output parameters through the sensitive field configuration manager, and read the content of the sensitive attribute fields through reflection technology; The encryption and decryption tool is used to encrypt the sensitive fields in the input parameter and decrypt the sensitive attribute fields in the output parameter, and the encrypted and decrypted sensitive attribute field contents are written back through the reflection technology.
2. The model-driven database encryption storage method according to claim 1, characterized in that: The encrypting of sensitive data by the encryption tool specifically includes: Define a Unicode code point separator, which is used to separate the ciphertext corresponding to each character in the original string; Establish hexadecimal obfuscation algorithm; Circularly traverse and convert each of the characters in the sensitive data string to be encrypted into a corresponding hexadecimal code point, and use the hexadecimal obfuscation algorithm to obfuscate the hexadecimal Unicode code point corresponding to each of the characters one by one; The obfuscated hexadecimal code points are concatenated into a new string using the Unicode code point separator and returned as ciphertext.
3. The model-driven database encryption storage method according to claim 2, characterized in that: Decrypting the sensitive information by using the decryption tool specifically includes: Split the ciphertext field into an array using the Unicode code point separator and loop through the array; The hexadecimal code points are converted back to character type one by one through an obfuscation restoration algorithm and concatenated into a result string.
4. The model-driven database encryption storage method according to claim 3, characterized in that: The obfuscation algorithm and the obfuscation restoration algorithm perform an XOR bitwise operation based on the ASCII value of each character.
5. The model-driven database encryption storage method according to claim 4, characterized in that: Two strings that have a containment relationship still maintain their original containment relationship after encryption and decryption, and there is no additional key distribution management during the encryption and decryption process.
6. A model-driven database encryption storage system, characterized in that: include: A definition module, wherein the definition module is used to define a configuration file and specify the name, content format and specification of the configuration file, wherein the content of the configuration file is the fully qualified name and attribute fields of the data table model entity class of sensitive information; An acquisition module, the acquisition module is used to create a sensitive field configuration manager, and load the configuration file through the sensitive field configuration manager to obtain sensitive information model entities and attribute fields; An encryption and decryption module, which is used to create encryption and decryption tools for sensitive information, and encrypt and decrypt the sensitive information through the encryption and decryption tools; An interception module, which is used to create a data access layer interceptor and intercept the input and output parameters of DAO data access through the data access layer interceptor; A reading module, the reading module is used to identify sensitive attribute fields in input parameters and output parameters through the sensitive field configuration manager, and read the content of the sensitive attribute fields through reflection technology; A write-back module is used to encrypt the sensitive fields in the input parameters and decrypt the sensitive attribute fields in the output parameters through the encryption and decryption tools, and write back the encrypted and decrypted sensitive attribute field contents through the reflection technology.
7. The model-driven database encryption storage system according to claim 6, characterized in that: The encryption and decryption module is also used for: Define a Unicode code point separator, which is used to separate the ciphertext corresponding to each character in the original string; Establish hexadecimal obfuscation algorithm; Circularly traverse and convert each of the characters in the sensitive data string to be encrypted into a corresponding hexadecimal code point, and use the hexadecimal obfuscation algorithm to obfuscate the hexadecimal Unicode code point corresponding to each of the characters one by one; The obfuscated hexadecimal code points are concatenated into a new string using the Unicode code point separator and returned as ciphertext.
8. The model-driven database encryption storage system according to claim 7, characterized in that: The encryption and decryption module is also used for: Split the ciphertext field into an array using the Unicode code point separator and loop through the array; The hexadecimal code points are converted back to character type one by one through an obfuscation restoration algorithm and concatenated into a result string.
9. The model-driven database encryption storage system according to claim 8, characterized in that: The obfuscation algorithm and the obfuscation restoration algorithm perform an XOR bitwise operation based on the ASCII value of each character.
10. The model-driven database encryption storage system according to claim 9, characterized in that: Two strings that have a containment relationship still maintain their original containment relationship after encryption and decryption, and there is no additional key distribution management during the encryption and decryption process.
Citation Information
Patent Citations
Method, system and equipment for storing sensitive information without perception and storage medium
CN115859332A
Data storage encryption method and device, electronic equipment and computer program product
CN117272358A
Implementation method and system for encrypted storage of application layer of full-configuration database sensitive field
CN118246056A
Method for storing file as audio frequency to achieve encryption, apparatus, and device
WO2021139172A1
Cited By
Method for automatically encrypting and decrypting sensitive data based on configuration
CN122634619A
A method for automatically encrypting and decrypting sensitive data based on configuration
CN122634619B
