Data encryption method and device, electronic equipment and computer readable medium
By detecting the structured statement type and using a replacement field table to perform field replacement and encryption on the structured statements in the database, the problems of low efficiency in modifying structured statements and leakage of sensitive fields are solved, thus achieving efficient database encryption.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING JINGDONG TUOXIAN TECH CO LTD
- Filing Date
- 2021-01-29
- Publication Date
- 2026-05-19
AI Technical Summary
In existing technologies, modifying structured statements in databases is inefficient and prone to omissions, leading to the leakage of sensitive fields. Furthermore, the modified fields need to be encoded into the source code, increasing coupling.
By detecting the statement type of the structured statement, the target structured statement is replaced and encrypted using a preset replacement field table, avoiding the encoding of modified fields into the source code, and making targeted modifications for different statement types.
It improves the efficiency of modifying structured statements, reduces the possibility of sensitive field leakage, and reduces the coupling between modified fields and code.
Smart Images

Figure CN113761567B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of this disclosure relate to the field of computer technology, and more specifically to data encryption methods, apparatus, electronic devices, and computer-readable media. Background Technology
[0002] A database is a repository for organizing, storing, and managing data according to data structures. Typically, data in a database is presented in the form of structured statements. With the development of information technology, databases are widely used in application development. Currently, when an application contains a large amount of data from its database, it is easy for information to be leaked. To reduce or avoid database leaks, data is usually encrypted by modifying the statements within the database.
[0003] However, the above approach usually has the following technical problems: the lack of detection of structured statements makes it easy to miss modifications to structured statements; at the same time, when modifying structured statements, the modified fields need to be encoded into the source code, resulting in low efficiency of modifying structured statements and easy leakage of sensitive fields. Summary of the Invention
[0004] The summary portion of this disclosure is intended to provide a brief overview of the concepts, which will be described in detail in the detailed description portion. This summary portion is not intended to identify key or essential features of the claimed technical solutions, nor is it intended to limit the scope of the claimed technical solutions.
[0005] Some embodiments of this disclosure provide data encryption methods, apparatuses, electronic devices, and computer-readable media to address one or more of the technical problems mentioned in the background section above.
[0006] In a first aspect, some embodiments of this disclosure provide a data encryption method, the method comprising: detecting the statement type of the target structured statement in response to the existence of a field table name included in a target structured statement in a preset configuration file; performing replacement processing on the fields included in the target structured statement according to the detected statement type and a preset replacement field table, wherein the replacement field table includes an encrypted field table and an indexed field table; and encrypting the field values in response to the existence of field values corresponding to the replacement fields in the target structured statement after the replacement processing.
[0007] Optionally, the above-mentioned replacement processing of the fields included in the target structured statement according to the detected statement type and the preset replacement field table includes: in response to the statement type being a query type, determining whether there are query fields among the various query fields included in the target structured statement that match the sensitive fields included in the configuration file; in response to determining that they exist, identifying the matched query fields as a group of query fields to be replaced; determining whether there are query condition fields among the various query condition fields included in the target structured statement that match the sensitive fields included in the configuration file; in response to determining that they exist, identifying the matched query condition fields as a group of query condition fields to be replaced; and performing replacement processing on the group of query fields to be replaced and the group of query condition fields to be replaced in the target structured statement through the above-mentioned replacement field table.
[0008] Optionally, the replacement process for the group of query fields to be replaced and the group of query conditions to be replaced in the target structured statement using the replacement field table includes: selecting an encrypted field from the encrypted field table corresponding to each query field to be replaced in the group of query fields to be replaced as a replacement encrypted field, thus obtaining a replacement encrypted field group; replacing each query field to be replaced in the group of query fields to be replaced in the target structured statement with a replacement encrypted field from the replacement encrypted field group; selecting an index field from the index field table corresponding to each query condition field to be replaced in the group of query conditions to be replaced as a replacement index field, thus obtaining a replacement index field group; and replacing each query condition field to be replaced in the group of query conditions to be replaced in the target structured statement with a replacement index field from the replacement index field group.
[0009] Optionally, the above-mentioned replacement processing of the fields included in the target structured statement according to the detected statement type and the preset replacement field table includes: in response to the statement type being modification type, determining whether there are any modification fields in the target structured statement that match the sensitive fields included in the configuration file; in response to determining that they exist, determining the matched modification fields as a group of modification fields to be replaced; determining whether there are any modification condition fields in the target structured statement that match the sensitive fields included in the configuration file; in response to determining that they exist, determining the matched modification condition fields as a group of modification condition fields to be replaced; and performing replacement processing on the group of modification fields to be replaced and the group of modification condition fields to be replaced in the target structured statement through the replacement field table.
[0010] Optionally, the replacement process for the target structured statement's group of fields to be replaced and the group of conditional fields to be replaced using the replacement field table includes: selecting, from the encrypted field table, an encrypted field corresponding to each field to be replaced in the group of fields to be replaced as a replacement encrypted field, thus obtaining a replacement encrypted field group; selecting, from the index field table, an index field corresponding to each field to be replaced in the group of fields to be replaced as a replacement index field, thus obtaining a replacement index field group; and performing a process on each replacement encrypted field in the replacement encrypted field group and the replacement index field corresponding to the aforementioned replacement encrypted field in the replacement index field group. The process involves combining fields to generate combined replacement modified fields, resulting in a combined replacement modified field group. Each field to be replaced in the target structured statement's field to be replaced modified field group is replaced with the corresponding combined replacement modified field in the combined replacement modified field group. From the index field table, the index field corresponding to each field to be replaced modified in the field to be replaced modified in the field to be replaced modified is selected as the replacement modified condition index field, resulting in a replacement modified condition index field group. Each field to be replaced in the target structured statement's field to be replaced modified condition field group is replaced with the corresponding replacement modified condition index field in the replacement modified condition index field group.
[0011] Optionally, the above-mentioned replacement processing of the fields included in the target structured statement according to the detected statement type and the preset replacement field table includes: in response to the statement type being an insertion type, determining whether there is an insertion field among the various insertion fields included in the target structured statement that matches the sensitive fields included in the configuration file; in response to determining that there is, determining the matching insertion field as a group of insertion fields to be replaced; determining whether there is an insertion condition field among the various insertion condition fields included in the target structured statement that matches the sensitive fields included in the configuration file; in response to determining that there is, determining the matching insertion condition field as a group of insertion condition fields to be replaced; and performing replacement processing on the group of insertion fields to be replaced and the group of insertion condition fields to be replaced in the target structured statement through the above-mentioned replacement field table.
[0012] Optionally, the replacement process of the target structured statement's group of fields to be replaced and the group of fields to be replaced using the replacement field table includes: selecting, from the encrypted field table, the encrypted field corresponding to each field to be replaced in the group of fields to be replaced as the replacement encrypted field, thus obtaining a group of replacement encrypted fields; selecting, from the index field table, the index field corresponding to each field to be replaced in the group of fields to be replaced as the replacement index field, thus obtaining a group of replacement index fields; and performing operations on each of the replacement encrypted fields in the group of fields to be replaced and the replacement index field corresponding to the encrypted field in the group of fields to be replaced. The process involves combining fields to generate a combined replacement insert field group. Each field to be replaced in the target structured statement's field group is replaced with the corresponding combined replacement insert field in the combined replacement insert field group. From the index field table, the index field corresponding to each field to be replaced in the field group is selected as the replacement insert condition index field, resulting in a replacement insert condition index field group. Each field to be replaced in the target structured statement's field group is then replaced with the corresponding replacement insert condition index field in the replacement insert condition index field group.
[0013] Optionally, the above-mentioned replacement processing of the fields included in the target structured statement according to the detected statement type and the preset replacement field table includes: in response to the statement type being a deletion type, determining whether there is a deletion condition field among the various deletion condition fields included in the target structured statement that matches the sensitive fields included in the configuration file; in response to determining that there is, determining the matching deletion condition field as a group of deletion condition fields to be replaced; and replacing the group of deletion condition fields to be replaced in the target structured statement using the above-mentioned replacement field table.
[0014] Optionally, the above-mentioned replacement process for the group of fields to be replaced and deleted in the target structured statement through the above-mentioned replacement field table includes: selecting the index field corresponding to each field to be replaced and deleted in the group of fields to be replaced and deleted from the above-mentioned index field table as the replacement and deletion index field, thereby obtaining the replacement and deletion index field group; and replacing each field to be replaced and deleted in the group of fields to be replaced and deleted in the target structured statement with the replacement and deletion index field corresponding to the field to be replaced and deleted in the above-mentioned replacement and deletion index field group.
[0015] Optionally, the above method further includes storing the encrypted target structured statement.
[0016] Secondly, some embodiments of this disclosure provide a data encryption apparatus, comprising: a detection unit configured to detect the statement type of the target structured statement in response to the existence of a field table name in a preset configuration file; a processing unit configured to perform replacement processing on the fields included in the target structured statement according to the detected statement type and a preset replacement field table, wherein the replacement field table includes an encrypted field table and an indexed field table; and an encryption unit configured to encrypt the field values in response to the existence of field values corresponding to the replacement fields in the target structured statement after the replacement processing.
[0017] Optionally, the processing unit is further configured to: in response to the statement type being a query type, determine whether there are query fields in the target structured statement that match the sensitive fields in the configuration file; in response to the determination that they exist, identify the matched query fields as a group of query fields to be replaced; determine whether there are query condition fields in the target structured statement that match the sensitive fields in the configuration file; in response to the determination that they exist, identify the matched query condition fields as a group of query condition fields to be replaced; and perform replacement processing on the group of query fields to be replaced and the group of query condition fields to be replaced in the target structured statement through the replacement field table.
[0018] Optionally, the processing unit is further configured to: select, from the above-mentioned encrypted field table, an encrypted field corresponding to each query field to be replaced in the above-mentioned query field group to be replaced as a replacement query encrypted field, thereby obtaining a replacement query encrypted field group; replace each query field to be replaced in the above-mentioned target structured statement in the query field group to be replaced with a replacement query encrypted field corresponding to the above-mentioned query field to be replaced in the above-mentioned replacement query encrypted field group; select, from the above-mentioned index field table, an index field corresponding to each query condition field to be replaced in the above-mentioned query condition field group to be replaced as a replacement query index field, thereby obtaining a replacement query index field group; and replace each query condition field to be replaced in the above-mentioned target structured statement in the query condition field group to be replaced with a replacement query index field corresponding to the above-mentioned query condition field to be replaced in the above-mentioned replacement query index field group.
[0019] Optionally, the processing unit is further configured to: in response to the statement type being modification type, determine whether there are any modification fields in the target structured statement that match the sensitive fields in the configuration file; in response to the determination that they exist, identify the matched modification fields as a group of modification fields to be replaced; determine whether there are any modification condition fields in the target structured statement that match the sensitive fields in the configuration file; in response to the determination that they exist, identify the matched modification condition fields as a group of modification condition fields to be replaced; and perform replacement processing on the group of modification fields to be replaced and the group of modification condition fields to be replaced in the target structured statement through the replacement field table.
[0020] Optionally, the processing unit is further configured to: select, from the encrypted field table, an encrypted field corresponding to each field to be replaced in the group of fields to be replaced as a replacement encrypted field, thereby obtaining a group of replacement encrypted fields; select, from the index field table, an index field corresponding to each field to be replaced in the group of fields to be replaced as a replacement index field, thereby obtaining a group of replacement index fields; and combine each replacement encrypted field in the group of replacement encrypted fields with the replacement index field corresponding to the aforementioned replacement encrypted field in the group of replacement index fields to generate a combined replacement field, thereby obtaining a combined... Replace the modified field group; replace each field to be replaced in the modified field group of the target structured statement with the combined modified field of the modified field group that corresponds to the modified field to be replaced; select the index field corresponding to each condition field to be replaced in the modified condition field group from the index field table as the replacement condition index field, and obtain the replacement condition index field group; replace each condition field to be replaced in the modified condition field group of the target structured statement with the replacement condition index field of the modified condition index field group that corresponds to the modified condition field to be replaced.
[0021] Optionally, the processing unit is further configured to: in response to the statement type being an insert type, determine whether there exists an insert field among the insert fields included in the target structured statement that matches the sensitive fields included in the configuration file; in response to determining that there exists, determine the matching insert field as a group of insert fields to be replaced; determine whether there exists an insert condition field among the insert condition fields included in the target structured statement that matches the sensitive fields included in the configuration file; in response to determining that there exists, determine the matching insert condition field as a group of insert condition fields to be replaced; and perform replacement processing on the group of insert fields to be replaced and the group of insert condition fields to be replaced in the target structured statement through the replacement field table.
[0022] Optionally, the processing unit is further configured to: select, from the encrypted field table, an encrypted field corresponding to each field to be replaced in the group of fields to be replaced as a replacement encrypted field, thereby obtaining a group of replacement encrypted fields; select, from the index field table, an index field corresponding to each field to be replaced in the group of fields to be replaced as a replacement index field, thereby obtaining a group of replacement index fields; and combine each replacement encrypted field in the group of replacement encrypted fields with the replacement index field corresponding to the aforementioned replacement encrypted field in the group of replacement index fields to generate a combined replacement field, thereby obtaining a combined... Replace the insertion field group; replace each insertion field to be replaced in the insertion field group to be replaced in the target structured statement with the corresponding combination insertion field in the combined insertion field group to be replaced; select the index field corresponding to each insertion condition field to be replaced in the insertion condition field group to be replaced from the index field table to be replaced as the replacement insertion condition index field, thus obtaining the replacement insertion condition index field group; replace each insertion condition field to be replaced in the insertion condition field group to be replaced in the target structured statement with the corresponding replacement insertion condition index field in the replacement insertion condition index field group to be replaced.
[0023] Optionally, the processing unit is further configured to: in response to the statement type being a deletion type, determine whether there is a deletion condition field among the deletion condition fields included in the target structured statement that matches the sensitive fields included in the configuration file; in response to determining that there is, determine the matching deletion condition field as a group of deletion condition fields to be replaced; and perform replacement processing on the group of deletion condition fields to be replaced in the target structured statement through the replacement field table.
[0024] Optionally, the processing unit is further configured to: select from the above index field table the index field corresponding to each of the above-mentioned condition fields to be replaced in the above-mentioned group of condition fields to be replaced as the replacement deletion index field, thereby obtaining the replacement deletion index field group; and replace each of the condition fields to be replaced in the above-mentioned group of condition fields to be replaced in the above-mentioned target structured statement with the replacement deletion index field corresponding to the above-mentioned condition field to be replaced in the above-mentioned replacement deletion index field group.
[0025] Optionally, the device further includes a storage unit configured to store the encrypted target structured statement.
[0026] Thirdly, some embodiments of this disclosure provide an electronic device, including: one or more processors; and a storage device having one or more programs stored thereon, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any implementation of the first aspect above.
[0027] Fourthly, some embodiments of this disclosure provide a computer-readable medium having a computer program stored thereon, wherein the program, when executed by a processor, implements the method described in any of the implementations of the first aspect above.
[0028] The above embodiments of this disclosure have the following beneficial effects: the data encryption methods of some embodiments of this disclosure reduce the possibility of missing modifications to structured statements, improve the efficiency of modifying structured statements, and reduce the possibility of leakage of sensitive fields. Specifically, the reasons for leakage of sensitive fields are: the structured statements are not detected, making it easy to miss modifications to the structured statements; at the same time, when modifying structured statements, the modified fields need to be encoded into the source code, resulting in low efficiency of modifying structured statements and easy leakage of sensitive fields. Based on this, the data encryption method of some embodiments of this disclosure first detects the statement type of the target structured statement in response to the existence of the field table names included in the target structured statement in a preset configuration file. Thus, different modification processes can be performed on statements of different statement types to avoid missing modifications to structured statements. Then, according to the detected statement type and the preset replacement field table, the fields included in the target structured statement are replaced. Finally, in response to the existence of field values corresponding to the replacement fields in the target structured statement after replacement processing, the field values are encrypted. Therefore, fields in the target structured statement can be replaced using a pre-defined replacement field table, avoiding the need to encode modified fields into the source code and reducing the coupling between modified (sensitive) fields and the code. This improves the efficiency of modifying structured statements and reduces the possibility of sensitive field leakage. Attached Figure Description
[0029] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and elements are not necessarily drawn to scale.
[0030] Figure 1 This is a schematic diagram illustrating an application scenario of the data encryption method according to some embodiments of this disclosure;
[0031] Figure 2 This is a flowchart of some embodiments of the data encryption method according to this disclosure;
[0032] Figure 3 This is a flowchart of some other embodiments of the data encryption method according to this disclosure;
[0033] Figure 4This is a flowchart of yet another embodiment of the data encryption method according to this disclosure;
[0034] Figure 5 This is a flowchart of some further embodiments of the data encryption method according to this disclosure;
[0035] Figure 6 This is a flowchart of some other embodiments of the data encryption method according to this disclosure;
[0036] Figure 7 These are schematic diagrams illustrating the structure of some embodiments of the data encryption apparatus according to this disclosure;
[0037] Figure 8 This is a schematic diagram of the structure of an electronic device suitable for implementing some embodiments of the present disclosure. Detailed Implementation
[0038] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.
[0039] It should also be noted that, for ease of description, only the parts relevant to the invention are shown in the accompanying drawings. Unless otherwise specified, the embodiments and features described in this disclosure can be combined with each other.
[0040] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are used only to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependencies.
[0041] It should be noted that the terms "a" and "a plurality of" used in this disclosure are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".
[0042] The names of messages or information exchanged between multiple devices in the embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.
[0043] This disclosure will now be described in detail with reference to the accompanying drawings and embodiments.
[0044] Figure 1 This is a schematic diagram illustrating an application scenario of a data encryption method according to some embodiments of the present disclosure.
[0045] exist Figure 1 In the application scenario, firstly, the computing device 101 can detect the statement type 104 of the target structured statement 102 in response to the existence of the field table name 1021 included in the target structured statement 102 in a preset configuration file 103. Here, the target structured statement 102 can be an SQL (Structured Query Language) statement being executed and intercepted by an interceptor. Here, the interceptor can be code used to intercept the execution task. Here, the field table name 1021 can be the name of a database field table. For example, the field table name 1021 can be test_table. Here, the configuration file 103 can be a file storing the sensitive field table names. Here, the statement type 104 can refer to the type of SQL statement. For example, the statement type 104 can be a query type, an update type, or an add type. Then, the computing device 101 can perform replacement processing on the fields included in the target structured statement 102 according to the detected statement type 104 and the preset replacement field table 105. Here, the replacement field table 105 includes an encrypted field table (not shown in the figure) and an index field table (not shown in the figure). Finally, the computing device 101 can encrypt the field values (not shown in the figure) in response to the existence of corresponding replacement field values in the target structured statement after replacement processing. Here, the encryption method can include, but is not limited to, at least one of the following: symmetric encryption, asymmetric encryption, etc.
[0046] It should be noted that the aforementioned computing device 101 can be either hardware or software. When the computing device is hardware, it can be implemented as a distributed cluster consisting of multiple servers or terminal devices, or as a single server or a single terminal device. When the computing device is software, it can be installed within the hardware devices listed above. It can be implemented as, for example, multiple software programs or software modules used to provide distributed services, or as a single software program or software module. No specific limitations are made here.
[0047] It should be understood that Figure 1 The number of computing devices shown is merely illustrative. Any number of computing devices can be used depending on implementation needs.
[0048] Continue to refer to Figure 2 The flowchart 200 illustrates some embodiments of a data encryption method according to the present disclosure. The data encryption method includes the following steps:
[0049] Step 201: In response to the fact that the field table names included in the target structured statement exist in a preset configuration file, the statement type of the target structured statement is detected.
[0050] In some embodiments, firstly, the entity executing the data encryption method (e.g. Figure 1 The computing device 101 shown can detect the statement type of the target structured statement in response to the presence of field table names in a preset configuration file. Here, the target structured statement can be an SQL (Structured Query Language) statement being executed, intercepted by an interceptor. Here, the interceptor can be code used to intercept the execution task. Here, the field table name can be the name of a database field table. For example, the field table name could be `test_table`. Here, the configuration file can be a file storing the sensitive field table names. Here, the statement type can refer to the type of SQL statement. For example, the statement type could be a query, modification, or addition statement.
[0051] In practice, taking a query as an example, the target structured statement could be "select phone,user_name from test_table where id='1231231'". Here, the table name is "test_table". The configuration file includes sensitive field table names such as "test_table; test1_table; test2_table". As an example, the execution entity can respond to the presence of the table name "test_table" in the preset configuration files "test_table; test1_table; test2_table", detecting that the statement type of the target structured statement "select phone,user_name from test_table where id='1231231'" is a query type "select".
[0052] Step 202: Based on the detected statement type and the preset replacement field table, perform replacement processing on the fields included in the target structured statement.
[0053] In some embodiments, the executing entity may perform replacement processing on the fields included in the target structured statement according to the detected statement type and a preset replacement field table. The replacement field table may include an encrypted field table and an indexed field table.
[0054] In practice, the aforementioned execution entity can perform replacement processing on the fields included in the target structured statement through the following steps:
[0055] The first step is to search for replacement schemes that match the above statement type from the locally stored replacement schemes. Here, a replacement scheme can refer to the replacement steps corresponding to the above statement type.
[0056] The replacement scheme described above may include the following sub-steps:
[0057] The first sub-step is to identify the matched fields as the group of fields to be replaced.
[0058] The second sub-step involves selecting the encrypted field corresponding to each field to be replaced in the above-mentioned field-to-replacement group from the encrypted field table above, thus obtaining the replacement encrypted field group.
[0059] The third sub-step involves selecting the index field corresponding to each field to be replaced in the above-mentioned field-to-be-replaced group from the index field table above, and using it as the replacement index field to obtain the replacement index field group.
[0060] The second step is to identify the query fields among the fields included in the target structured statement that match the sensitive fields included in the configuration file. For example, the sensitive fields included in the configuration file could be {phone; mobile_phone}.
[0061] The third step is to replace the fields included in the target structured statement according to the above replacement scheme and the preset replacement field table.
[0062] The third step mentioned above may include the following sub-steps:
[0063] The first sub-step involves concatenating each replacement encrypted field in the aforementioned replacement encrypted field group with the corresponding replacement index field in the aforementioned replacement index field group to generate a concatenated replacement field, thus obtaining a concatenated replacement field group.
[0064] The second sub-step can replace each field to be replaced in the field to be replaced group in the target structured statement with the corresponding field to be replaced in the concatenation replacement field group.
[0065] As an example, the encrypted field table could include {phone = phone_encrypted; mobile_phone = mobile_phone_encrypted}. The indexed field table could include {phone = phone_index; mobile_phone = mobile_phone_index}. The target structured statement could be "select phone,user_name from test_table where id = '1231231'". The sensitive field "phone" can be found in the target structured statement. The encrypted field corresponding to the sensitive field "phone" can be found in the encrypted field table as "phone_encrypted". The indexed field corresponding to the sensitive field "phone" can be found in the indexed field table as "phone_index". The encrypted field "phone_encrypted" and the indexed field "phone_index" are concatenated to generate the concatenated replacement field "phone_encrypted-phone_index". The sensitive field "phone" in the target structured statement "select phone,user_name from test_table where id = '1231231'" can be replaced with "phone_encrypted-phone_index".
[0066] Step 203: In response to the existence of a field value corresponding to the replacement field in the target structured statement after replacement processing, the field value is encrypted.
[0067] In some embodiments, in response to the existence of a field value corresponding to the replacement field in the target structured statement after the replacement process, the execution entity may encrypt the field value. Here, the encryption process can be symmetric encryption or asymmetric encryption. Here, the replacement field can refer to the field in the target structured statement that is being replaced.
[0068] Optionally, the encrypted target structured statement can be stored. For example, the encrypted target structured statement can be stored on a local server.
[0069] The above embodiments of this disclosure have the following beneficial effects: the data encryption methods of some embodiments of this disclosure reduce the possibility of missing modifications to structured statements, improve the efficiency of modifying structured statements, and reduce the possibility of leakage of sensitive fields. Specifically, the reasons for leakage of sensitive fields are: the structured statements are not detected, making it easy to miss modifications to the structured statements; at the same time, when modifying structured statements, the modified fields need to be encoded into the source code, resulting in low efficiency of modifying structured statements and easy leakage of sensitive fields. Based on this, the data encryption method of some embodiments of this disclosure first detects the statement type of the target structured statement in response to the existence of the field table names included in the target structured statement in a preset configuration file. Thus, different modification processes can be performed on statements of different statement types to avoid missing modifications to structured statements. Then, according to the detected statement type and the preset replacement field table, the fields included in the target structured statement are replaced. Finally, in response to the existence of field values corresponding to the replacement fields in the target structured statement after replacement processing, the field values are encrypted. Therefore, fields in the target structured statement can be replaced using a pre-defined replacement field table, avoiding the need to encode modified fields into the source code and reducing the coupling between modified (sensitive) fields and the code. This improves the efficiency of modifying structured statements and reduces the possibility of sensitive field leakage.
[0070] Further reference Figure 3 The diagram illustrates flowcharts of some other embodiments of the data encryption method according to this disclosure. The data encryption method includes the following steps:
[0071] Step 301: In response to the fact that the field table names included in the target structured statement exist in the preset configuration file, the statement type of the target structured statement is detected.
[0072] In some embodiments, the specific implementation of step 301 and its resulting technical effects can be found in [reference needed]. Figure 2 Step 201 in the corresponding embodiments will not be repeated here.
[0073] Step 302: In response to the statement type being a query type, determine whether there are any query fields among the various query fields included in the target structured statement that match the sensitive fields included in the configuration file.
[0074] In some embodiments, in response to the above statement type being a query type, the execution body of the data encryption method (e.g.) Figure 1 The computing device 101 shown can determine whether there are any query fields among the various query fields included in the target structured statement that match the sensitive fields included in the configuration file.
[0075] As an example, the target structured statement could be "select mobile_phone,user_name from test_table where phone='1231231'". The table name for the sensitive fields included in the configuration file could be "phone;mobile_phone". The query field included in the target structured statement is "mobile_phone".
[0076] Step 303: In response to the determination that it exists, the matched query fields are identified as the group of query fields to be replaced.
[0077] In some embodiments, in response to determining that a match exists, the execution entity may identify the matched query fields as the group of query fields to be replaced.
[0078] As an example, the matching "mobile_phone" can be identified as the query field to be replaced.
[0079] Step 304: Determine whether any of the query condition fields in the target structured statement match the sensitive fields in the configuration file.
[0080] In some embodiments, the execution entity may determine whether there are any query condition fields among the various query condition fields included in the target structured statement that match the sensitive fields included in the configuration file.
[0081] As an example, the target structured statement "select mobile_phone,user_name from test_tablewhere phone='1231231'" includes the query condition field "phone". The configuration file can include sensitive field table names such as "phone;mobile_phone". The target structured statement includes the query condition field "phone".
[0082] Step 305: In response to the determination of existence, the matched query condition field is identified as the group of query condition fields to be replaced.
[0083] In some embodiments, the execution entity may, in response to determining the existence, identify the matched query condition field as the group of query condition fields to be replaced.
[0084] As an example, the above-mentioned execution entity can identify the matched query condition field "phone" as the query condition field to be replaced.
[0085] Step 306: Replace the query field group and query condition field group to be replaced in the target structured statement using the replacement field table.
[0086] In some embodiments, the replacement field table includes an encrypted field table and an indexed field table. The execution entity can use the replacement field table to perform the following steps to replace the query field group and query condition field group in the target structured statement:
[0087] The first step is to select the encrypted field corresponding to each query field to be replaced in the above-mentioned group of query fields to be replaced from the encrypted field table above as the replacement query encrypted field, thus obtaining the replacement query encrypted field group.
[0088] As an example, the encrypted field table could be {phone = phone_encrypted; mobile_phone = mobile_phone_encrypted}. The query field to be replaced could be "mobile_phone". The encrypted field "mobile_phone_encrypted" corresponding to the query field "mobile_phone" can be selected from the encrypted field table {phone = phone_encrypted; mobile_phone = mobile_phone_encrypted} as the replacement encrypted field.
[0089] The second step is to replace each query field to be replaced in the group of query fields to be replaced in the target structured statement with the corresponding encrypted field in the encrypted field group of the replaced query fields.
[0090] As an example, the query field "mobile_phone" to be replaced in the target structured statement "select mobile_phone,user_name fromtest_table where phone='1231231'" can be replaced with the corresponding encrypted query field "mobile_phone_encrypted".
[0091] The third step is to select the index field corresponding to each query condition field to be replaced in the above group of query condition fields to be replaced from the index field table above as the replacement query index field, so as to obtain the replacement query index field group.
[0092] As an example, the index field table could be {phone = phone_index; mobile_phone = mobile_phone_index}. The field to be replaced in the query condition could be "phone". The index field "phone_index" corresponding to the field "phone" in the query condition table {phone = phone_index; mobile_phone = mobile_phone_index} can be selected as the replacement query index field.
[0093] The fourth step is to replace each query condition field in the group of query condition fields to be replaced in the target structured statement with the corresponding replacement query index field in the group of replacement query index fields.
[0094] As an example, the field "phone" in the target structured statement "select mobile_phone,user_name fromtest_table where phone='1231231'" can be replaced with the corresponding replacement query index field "phone_index".
[0095] Step 307: In response to the existence of a field value corresponding to the replacement field in the target structured statement after replacement processing, the field value is encrypted.
[0096] In some embodiments, the specific implementation of step 307 and its resulting technical effects can be found in [reference needed]. Figure 2 Step 203 in the corresponding embodiments will not be repeated here.
[0097] from Figure 3 It can be seen that, with Figure 2 Compared to the description of some corresponding embodiments, Figure 3 In some corresponding embodiments, process 300 demonstrates the categorized replacement of different sensitive fields in a structured query statement using a pre-defined replacement field table. This reduces the possibility of overlooking modifications to the structured statement, avoids encoding sensitive query fields into the source code, and reduces the coupling between query fields (sensitive fields) and the code. Consequently, it improves the efficiency of replacing sensitive fields in the structured statement and reduces the possibility of sensitive field leakage.
[0098] Further reference Figure 4 This illustrates further embodiments of a data encryption method according to the present disclosure. The data encryption method includes the following steps:
[0099] Step 401: In response to the fact that the field table names included in the target structured statement exist in the preset configuration file, the statement type of the target structured statement is detected.
[0100] In some embodiments, the specific implementation of step 401 and its resulting technical effects can be found in [reference needed]. Figure 4 Step 201 in the corresponding embodiments will not be repeated here.
[0101] Step 402: In response to the statement type being modification type, determine whether there are any modification fields among the modification fields included in the target structured statement that match the sensitive fields included in the configuration file.
[0102] In some embodiments, in response to the above statement type being modification type, the execution subject of the data encryption method (e.g.) Figure 1 The computing device 101 shown can determine whether there are any modified fields among the various modified fields included in the target structured statement that match the sensitive fields included in the configuration file.
[0103] As an example, the target structured statement could be "update test_table set mobile_phone='1231231'where phone=1111". The sensitive fields included in the configuration file could be "phone;mobile_phone". The target structured statement would modify the field "mobile_phone".
[0104] Step 403: In response to the determination of existence, the matched modified field is identified as the group of modified fields to be replaced.
[0105] In some embodiments, in response to determining that a field exists, the execution entity may identify the matched modified field as the group of modified fields to be replaced.
[0106] As an example, the matching "mobile_phone" can be identified as the field to be replaced or modified.
[0107] Step 404: Determine whether any of the modification condition fields in the target structured statement match the sensitive fields in the configuration file.
[0108] In some embodiments, the execution entity may determine whether there is a modification condition field among the various modification condition fields included in the target structured statement that matches the sensitive fields included in the configuration file.
[0109] As an example, the target structured statement "update test_table set mobile_phone='1231231'where phone=1111" includes the field to be modified as "phone".
[0110] Step 405: In response to the determination of existence, the matched modification condition field is identified as the group of modification condition fields to be replaced.
[0111] In some embodiments, the execution entity may, in response to determining the existence, identify the matched modification condition field as the group of modification condition fields to be replaced.
[0112] As an example, the aforementioned executing entity can identify the matched modification condition field "phone" as the modification condition field to be replaced.
[0113] Step 406: Replace the target structured statement's field group and condition field group with the replacement field table.
[0114] In some embodiments, the replacement field table includes an encrypted field table and an indexed field table. The execution entity can use the replacement field table to perform replacement processing on the target structured statement's group of fields to be replaced and the group of conditions to be replaced using the following steps:
[0115] The first step is to select the encrypted field corresponding to each field to be replaced in the above-mentioned group of fields to be replaced from the encrypted field table above, and then use it as the replacement encrypted field to obtain the replacement encrypted field group.
[0116] As an example, the encrypted field table could be {phone = phone_encrypted; mobile_phone = mobile_phone_encrypted}. The field to be replaced or modified could be "mobile_phone". The encrypted field "mobile_phone_encrypted" corresponding to the field to be replaced or modified "mobile_phone" can be selected from the encrypted field table {phone = phone_encrypted; mobile_phone = mobile_phone_encrypted} as the replacement encrypted field.
[0117] The second step is to select the index field corresponding to each field to be replaced in the above-mentioned group of fields to be replaced from the index field table as the replacement index field, thus obtaining the replacement index field group.
[0118] As an example, the index field table could be {phone = phone_index; mobile_phone = mobile_phone_index}. The field to be replaced or modified could be "mobile_phone". The index field "mobile_phone_index" corresponding to the field to be replaced or modified, "phone", can be selected from the index field table {phone = phone_index; mobile_phone = mobile_phone_index} as the replacement index field.
[0119] The third step involves combining each of the aforementioned encrypted replacement fields in the encrypted replacement field group with the corresponding replacement index field in the aforementioned index field group to generate a combined replacement field, thus obtaining a combined replacement field group. Here, "combination" can refer to concatenation.
[0120] As an example, the replacement and modification encrypted field "mobile_phone_encrypted" and the corresponding replacement and modification index field "mobile_phone_index" can be concatenated to generate the combined replacement and modification field "mobile_phone_encrypted-mobile_phone_index".
[0121] The fourth step is to replace each field to be replaced in the target structured statement with the corresponding combined replacement field in the combined replacement field group.
[0122] Fifth, select the index field corresponding to each field to be replaced in the group of fields to be replaced from the index field table above as the replacement condition index field, and obtain the replacement condition index field group.
[0123] Step 6: Replace each field in the field group to be replaced in the target structured statement with the corresponding replacement condition index field in the replacement condition index field group.
[0124] Step 407: In response to the existence of a field value corresponding to the replacement field in the target structured statement after replacement processing, the field value is encrypted.
[0125] In some embodiments, the specific implementation of step 407 and its resulting technical effects can be found in [reference needed]. Figure 2 Step 203 in the corresponding embodiments will not be repeated here.
[0126] from Figure 4 It can be seen that, with Figure 2 Compared to the description of some corresponding embodiments, Figure 4 In some corresponding embodiments, process 400 demonstrates the categorized replacement of different sensitive fields in the structured statement of the modification class through a preset replacement field table. This reduces the possibility of overlooking modifications to the structured statement, avoids encoding modified fields into the source code, and reduces the coupling between modified fields (sensitive fields) and the code. Consequently, it improves the efficiency of replacing sensitive fields in the structured statement and reduces the possibility of sensitive field leakage.
[0127] Further reference Figure 5 Further embodiments of the data encryption method according to this disclosure are shown. The data encryption method includes the following steps:
[0128] Step 501: In response to the fact that the field table names included in the target structured statement exist in the preset configuration file, the statement type of the target structured statement is detected.
[0129] In some embodiments, the specific implementation of step 501 and its resulting technical effects can be found in [reference needed]. Figure 5 Step 201 in the corresponding embodiments will not be repeated here.
[0130] Step 502: In response to the statement type being insert, determine whether there is an insert field among the insert fields included in the target structured statement that matches the sensitive fields included in the configuration file.
[0131] In some embodiments, in response to the above statement type being modification type, the execution subject of the data encryption method (e.g.) Figure 1 The computing device 101 shown can determine whether any of the modified fields included in the target structured statement match the sensitive fields included in the configuration file. For example, the target structured statement could be "inserttest_table(id,phone)values(1111,'1231231')".
[0132] Step 503: In response to the determination of existence, the matched insertion field is identified as the group of insertion fields to be replaced.
[0133] In some embodiments, the execution entity may, in response to determining the existence, identify the matched insertion field as the group of insertion fields to be replaced.
[0134] Step 504: Determine whether any of the insert condition fields in the target structured statement match the sensitive fields in the configuration file.
[0135] In some embodiments, the execution entity may determine whether there is an insertion condition field among the various insertion condition fields included in the target structured statement that matches the sensitive fields included in the configuration file.
[0136] Step 505: In response to the determination that it exists, the matched insert condition field is identified as the group of insert condition fields to be replaced.
[0137] In some embodiments, the execution entity may, in response to determining the existence, identify the matched insertion condition field as the group of insertion condition fields to be replaced.
[0138] Step 506: Replace the insertion field group and insertion condition field group in the target structured statement using the replacement field table.
[0139] In some embodiments, the replacement field table includes an encrypted field table and an indexed field table. The execution entity can use the replacement field table to perform the following steps to replace the group of fields to be replaced and the group of fields to be replaced in the target structured statement:
[0140] The first step is to select the encrypted field corresponding to each field to be replaced in the above-mentioned field to be replaced from the encrypted field table as the replacement encrypted field, thus obtaining the replacement encrypted field group.
[0141] The second step is to select the index field corresponding to each field to be replaced in the above-mentioned group of fields to be replaced from the index field table as the replacement insertion index field, thus obtaining the replacement insertion index field group.
[0142] The third step is to combine each of the above-mentioned replacement insertion encrypted fields in the replacement insertion encrypted field group with the replacement insertion index field corresponding to the above-mentioned replacement insertion encrypted field in the above-mentioned replacement insertion index field group to generate a combined replacement insertion field, thus obtaining a combined replacement insertion field group.
[0143] The fourth step is to replace each field to be replaced in the target structured statement with a combined replacement field from the combined replacement field group that corresponds to the field to be replaced.
[0144] Fifth step: Select the index field corresponding to each of the insertion condition fields to be replaced in the above group of insertion condition fields to be replaced from the index field table above as the replacement insertion condition index field, and obtain the replacement insertion condition index field group.
[0145] Step 6: Replace each field in the field to be replaced in the target structured statement with the corresponding index field in the index field to be replaced.
[0146] Step 507: In response to the existence of a field value corresponding to the replacement field in the target structured statement after replacement processing, the field value is encrypted.
[0147] In some embodiments, the specific implementation of step 507 and its resulting technical effects can be found in [reference needed]. Figure 2 Step 203 in the corresponding embodiments will not be repeated here.
[0148] from Figure 5 It can be seen that, with Figure 2 Compared to the description of some corresponding embodiments, Figure 5 In some corresponding embodiments, process 500 demonstrates the categorized replacement of different sensitive fields in the structured statement of the insertion class through a preset replacement field table. This reduces the possibility of overlooking modifications to the structured statement, avoids encoding the insertion fields into the source code, and reduces the coupling between the insertion fields (sensitive fields) and the code. Consequently, it improves the efficiency of replacing sensitive fields in the structured statement and reduces the possibility of sensitive field leakage.
[0149] Further reference Figure 6 This illustrates further embodiments of a data encryption method according to the present disclosure. The data encryption method includes the following steps:
[0150] Step 601: In response to the fact that the field table names included in the target structured statement exist in a preset configuration file, the statement type of the target structured statement is detected.
[0151] In some embodiments, the specific implementation of step 601 and its resulting technical effects can be found in [reference needed]. Figure 6 Step 201 in the corresponding embodiments will not be repeated here.
[0152] Step 602: In response to the above statement type being deletion type, determine whether there is a deletion condition field among the various deletion condition fields included in the above target structured statement that matches the sensitive fields included in the above configuration file.
[0153] In some embodiments, in response to the above statement type being a deletion type, the execution body of the data encryption method (e.g., Figure 1 The computing device 101 shown can determine whether there is a deletion condition field among the various deletion condition fields included in the target structured statement that matches the sensitive fields included in the configuration file.
[0154] Step 603: In response to the determination of existence, the matched deletion condition field is identified as the group of deletion condition fields to be replaced.
[0155] In some embodiments, the execution entity may, in response to determining the existence, identify the matched deletion condition field as the group of deletion condition fields to be replaced.
[0156] Step 604: Replace the fields to be replaced or deleted in the target structured statement using the replacement field table.
[0157] In some embodiments, the replacement field table includes an encrypted field table and an indexed field table. The execution entity can use the replacement field table to perform the replacement process on the group of fields to be deleted in the target structured statement using the following steps:
[0158] The first step is to select the index field corresponding to each field in the group of fields to be replaced and deleted from the index field table above as the replacement and deletion index field, thus obtaining the replacement and deletion index field group.
[0159] The second step is to replace each field in the field group of fields to be replaced and deleted in the target structured statement with the corresponding field in the field group of fields to be replaced and deleted.
[0160] Step 605: In response to the existence of a field value corresponding to the replacement field in the target structured statement after replacement processing, the field value is encrypted.
[0161] In some embodiments, the specific implementation of step 605 and its resulting technical effects can be found in [reference needed]. Figure 2 Step 203 in the corresponding embodiments will not be repeated here.
[0162] from Figure 6 It can be seen that, with Figure 2 Compared to the description of some corresponding embodiments, Figure 6 In some corresponding embodiments, process 600 embodies the replacement of sensitive fields in the structured statement of the deletion class using a preset replacement field table. This reduces the possibility of overlooking modifications to the structured statement, avoids encoding the deletion field into the source code, and reduces the coupling between the deletion field (sensitive field) and the code. Consequently, it improves the efficiency of replacing sensitive fields in the structured statement and reduces the possibility of sensitive field leakage.
[0163] Further reference Figure 7 As an implementation of the methods shown in the above figures, this disclosure provides some embodiments of a data encryption device, which are similar to... Figure 2Corresponding to the method embodiments shown, the device can be specifically applied to various electronic devices.
[0164] like Figure 7 As shown, a data encryption device 700 in some embodiments includes: a detection unit 701 configured to detect the statement type of the target structured statement in response to the existence of a field table name in a preset configuration file; a processing unit 702 configured to perform replacement processing on the fields included in the target structured statement according to the detected statement type and a preset replacement field table, wherein the replacement field table includes an encrypted field table and an indexed field table; and an encryption unit 703 configured to encrypt the field value in response to the existence of a field value corresponding to the replacement field in the target structured statement after the replacement processing.
[0165] In some optional implementations of certain embodiments, the processing unit 702 is further configured to: in response to the statement type being a query type, determine whether there are query fields in the target structured statement that match the sensitive fields in the configuration file; in response to determining that there are, determine the matched query fields as a group of query fields to be replaced; determine whether there are query condition fields in the target structured statement that match the sensitive fields in the configuration file; in response to determining that there are, determine the matched query condition fields as a group of query condition fields to be replaced; and perform replacement processing on the group of query fields to be replaced and the group of query condition fields to be replaced in the target structured statement through the replacement field table.
[0166] In some optional implementations of certain embodiments, the processing unit 702 is further configured to: select, from the encrypted field table, an encrypted field corresponding to each query field to be replaced in the group of query fields to be replaced as a replacement query encrypted field, thereby obtaining a replacement query encrypted field group; replace each query field to be replaced in the group of query fields to be replaced in the target structured statement with a replacement query encrypted field corresponding to the query field to be replaced in the replacement query encrypted field group; select, from the index field table, an index field corresponding to each query condition field to be replaced in the group of query condition fields to be replaced as a replacement query index field, thereby obtaining a replacement query index field group; and replace each query condition field to be replaced in the group of query condition fields to be replaced in the target structured statement with a replacement query index field corresponding to the query condition field to be replaced in the replacement query index field group.
[0167] In some optional implementations of certain embodiments, the processing unit 702 is further configured to: in response to the statement type being a modification type, determine whether there exists a modification field among the various modification fields included in the target structured statement that matches a sensitive field included in the configuration file; in response to determining that there exists a modification field, determine the matched modification field as a group of modification fields to be replaced; determine whether there exists a modification condition field among the various modification condition fields included in the target structured statement that matches a sensitive field included in the configuration file; in response to determining that there exists a modification condition field, determine the matched modification condition field as a group of modification condition fields to be replaced; and perform replacement processing on the group of modification fields to be replaced and the group of modification condition fields to be replaced in the target structured statement through the replacement field table.
[0168] In some optional implementations of certain embodiments, the processing unit 702 is further configured to: select, from the encrypted field table, an encrypted field corresponding to each field to be replaced in the group of fields to be replaced as a replacement modified encrypted field, thereby obtaining a replacement modified encrypted field group; select, from the index field table, an index field corresponding to each field to be replaced in the group of fields to be replaced as a replacement modified index field, thereby obtaining a replacement modified index field group; and combine each replacement modified encrypted field in the replacement modified encrypted field group with the replacement modified index field corresponding to the aforementioned replacement modified encrypted field in the replacement modified index field group to generate a combined replacement modified encrypted field. Modify the field to obtain a combined replacement modification field group; replace each field to be replaced in the target structured statement's field to be replaced modification group with the combined replacement modification field corresponding to the field to be replaced in the combined replacement modification field group; select the index field corresponding to each condition field to be replaced in the condition field group from the index field table as the replacement modification condition index field, thus obtaining a replacement modification condition index field group; replace each field to be replaced in the target structured statement's condition field group with the replacement modification condition index field corresponding to the condition field to be replaced in the replacement modification condition index field group.
[0169] In some optional implementations of certain embodiments, the processing unit 702 is further configured to: in response to the statement type being an insert type, determine whether there exists an insert field among the insert fields included in the target structured statement that matches the sensitive fields included in the configuration file; in response to determining that there exists, determine the matching insert field as a group of insert fields to be replaced; determine whether there exists an insert condition field among the insert condition fields included in the target structured statement that matches the sensitive fields included in the configuration file; in response to determining that there exists, determine the matching insert condition field as a group of insert condition fields to be replaced; and perform replacement processing on the group of insert fields to be replaced and the group of insert condition fields to be replaced in the target structured statement through the replacement field table.
[0170] In some optional implementations of certain embodiments, the processing unit 702 is further configured to: select, from the encrypted field table, an encrypted field corresponding to each field to be replaced in the group of fields to be replaced as a replacement encrypted field, to obtain a replacement encrypted field group; select, from the index field table, an index field corresponding to each field to be replaced in the group of fields to be replaced as a replacement index field, to obtain a replacement index field group; and combine each replacement encrypted field in the replacement encrypted field group with the replacement index field corresponding to the replacement encrypted field in the replacement index field group to generate a combined replacement insertion field. The input field is used to obtain a combined replacement insertion field group; each field to be replaced in the target structured statement is replaced with a combined replacement insertion field corresponding to the field to be replaced in the combined replacement insertion field group; from the index field table, the index field corresponding to each field to be replaced in the target structured statement is selected as the replacement insertion condition index field, resulting in a replacement insertion condition index field group; each field to be replaced in the target structured statement is replaced with a replacement insertion condition index field corresponding to the field to be replaced in the replacement insertion condition index field group.
[0171] In some optional implementations of some embodiments, the processing unit 702 is further configured to: in response to the statement type being a deletion type, determine whether there is a deletion condition field among the deletion condition fields included in the target structured statement that matches the sensitive fields included in the configuration file; in response to determining that there is, determine the matching deletion condition field as a group of deletion condition fields to be replaced; and perform replacement processing on the group of deletion condition fields to be replaced in the target structured statement through the replacement field table.
[0172] In some optional implementations of some embodiments, the processing unit 702 is further configured to: select an index field from the index field table corresponding to each of the condition fields to be replaced in the group of condition fields to be replaced as a replacement deletion index field, thereby obtaining a group of replacement deletion index fields; and replace each of the condition fields to be replaced in the group of condition fields to be replaced in the target structured statement with a replacement deletion index field in the group of replacement deletion index fields corresponding to the condition fields to be replaced.
[0173] Optionally, the device 700 further includes a storage unit configured to store the encrypted target structured statement.
[0174] It is understandable that the units described in the device 700 are related to the reference. Figure 2 The steps in the described method correspond to each other. Therefore, the operations, features, and beneficial effects described above for the method also apply to the device 700 and the units contained therein, and will not be repeated here.
[0175] The following is for reference. Figure 8 It illustrates electronic devices suitable for implementing some embodiments of this disclosure (e.g., Figure 1 A schematic diagram of the structure of the computing device 101)800. Electronic devices in some embodiments of this disclosure may include, but are not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 8 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments of this disclosure.
[0176] like Figure 8 As shown, the electronic device 800 may include a processing device (e.g., a central processing unit, a graphics processor, etc.) 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage device 808 into a random access memory (RAM) 803. The RAM 803 also stores various programs and data required for the operation of the electronic device 800. The processing device 801, ROM 802, and RAM 803 are interconnected via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0177] Typically, the following devices can be connected to I / O interface 805: input devices 806 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 807 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 808 including, for example, magnetic tapes, hard disks, etc.; and communication devices 809. Communication device 809 allows electronic device 800 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 8 An electronic device 800 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively. Figure 8 Each box shown can represent a device or multiple devices as needed.
[0178] In particular, according to some embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, some embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 809, or installed from a storage device 808, or installed from a ROM 802. When the computer program is executed by the processing device 801, it performs the functions defined in the methods of some embodiments of this disclosure.
[0179] It should be noted that, in some embodiments of this disclosure, the computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium may be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In some embodiments of this disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In some embodiments of this disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0180] In some implementations, clients and servers can communicate using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol) and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet of Things), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future-developed networks.
[0181] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device. The aforementioned computer-readable medium carries one or more programs that, when executed by the electronic device, cause the electronic device to: detect the statement type of the target structured statement in response to the existence of field table names included in the target structured statement in a preset configuration file; perform replacement processing on the fields included in the target structured statement according to the detected statement type and a preset replacement field table, wherein the replacement field table includes an encrypted field table and an indexed field table; and encrypt the field values in response to the existence of corresponding replacement field values in the target structured statement after the replacement processing.
[0182] Computer program code for performing operations of some embodiments of this disclosure can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0183] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0184] The units described in some embodiments of this disclosure can be implemented in software or hardware. The described units can also be housed in a processor; for example, a processor may be described as including a detection unit, a processing unit, and an encryption unit. The names of these units do not necessarily limit the unit itself; for example, a detection unit may be described as "a unit that detects the statement type of the target structured statement in response to the existence of field table names in a preset configuration file."
[0185] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), System-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.
[0186] The above description is merely a selection of preferred embodiments of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of the invention involved in the embodiments of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described inventive concept. For example, technical solutions formed by substituting the above-described features with (but not limited to) technical features with similar functions disclosed in the embodiments of this disclosure.
Claims
1. A data encryption method, comprising: In response to the fact that the field table names included in the target structured statement exist in a preset configuration file, the statement type of the target structured statement is detected; Based on the detected statement type and a preset replacement field table, the fields included in the target structured statement are replaced. The replacement field table includes an encrypted field table and an indexed field table. The replacement process for the fields included in the target structured statement is performed through the following steps: The matched fields are identified as the group of fields to be replaced; Select the encrypted field corresponding to each field to be replaced in the field to be replaced group from the encrypted field table to obtain the replacement encrypted field group; Select the index field corresponding to each field to be replaced in the field to be replaced group from the index field table as the replacement index field to obtain the replacement index field group; Each of the replacement encrypted fields in the replacement encrypted field group and the corresponding replacement index field in the replacement index field group are concatenated to generate a concatenated replacement field, thus obtaining a concatenated replacement field group; Replace each field to be replaced in the field group to be replaced in the target structured statement with the corresponding field to be replaced in the concatenated replacement field group; In response to the existence of a field value corresponding to the replacement field in the target structured statement after replacement processing, the field value is encrypted.
2. The method according to claim 1, wherein, The step of replacing fields in the target structured statement based on the detected statement type and a preset replacement field table includes: In response to the statement type being a query type, determine whether there is a query field among the various query fields included in the target structured statement that matches the sensitive fields included in the configuration file; In response to the confirmation of existence, the matched query fields are identified as the group of query fields to be replaced; Determine whether any of the query condition fields included in the target structured statement match the sensitive fields included in the configuration file; In response to the determination of existence, the matched query condition fields are identified as the group of query condition fields to be replaced; The replacement field table is used to replace the query field group and query condition field group in the target structured statement.
3. The method according to claim 2, wherein, The process of replacing the query field group and query condition field group in the target structured statement through the replacement field table includes: Select the encrypted field corresponding to each query field to be replaced in the query field group to be replaced from the encrypted field table as the replacement query encrypted field to obtain the replacement query encrypted field group; Replace each query field to be replaced in the group of query fields to be replaced in the target structured statement with the corresponding encrypted query field in the group of encrypted query fields to be replaced; Select the index field corresponding to each query condition field to be replaced in the query condition field group from the index field table as the replacement query index field to obtain the replacement query index field group; Replace each query condition field in the group of query condition fields to be replaced in the target structured statement with the corresponding replacement query index field in the group of replacement query index fields.
4. The method according to claim 1, wherein, The step of replacing fields in the target structured statement based on the detected statement type and a preset replacement field table includes: In response to the statement type being modification type, determine whether there is a modification field among the various modification fields included in the target structured statement that matches the sensitive fields included in the configuration file; In response to the confirmation of existence, the matched modified fields are identified as the group of modified fields to be replaced; Determine whether any of the modification condition fields included in the target structured statement match the sensitive fields included in the configuration file; In response to the determination of existence, the matched modification condition field is identified as the group of modification condition fields to be replaced; The replacement field table is used to replace the target structured statement's group of fields to be replaced and the group of conditions to be replaced.
5. The method according to claim 4, wherein, The process of replacing the target structured statement's field group and condition field group using the replacement field table includes: Select the encrypted field corresponding to each field to be replaced in the group of fields to be replaced from the encrypted field table as the replacement and modification encrypted field to obtain the replacement and modification encrypted field group; Select the index field corresponding to each field to be replaced in the group of fields to be replaced from the index field table as the replacement index field to obtain the replacement index field group; Each replacement and modification encrypted field in the replacement and modification encrypted field group and the corresponding replacement and modification index field in the replacement and modification index field group are combined to generate a combined replacement and modification field, thus obtaining a combined replacement and modification field group. Replace each field to be replaced in the target structured statement with the combined replacement field in the combined replacement field group that corresponds to the field to be replaced. Select the index field corresponding to each of the condition fields to be replaced in the group of condition fields to be replaced from the index field table as the replacement condition index field to obtain the replacement condition index field group; Replace each field in the field group to be replaced in the target structured statement with the corresponding replacement condition index field in the replacement condition index field group.
6. The method according to claim 1, wherein, The step of replacing fields in the target structured statement based on the detected statement type and a preset replacement field table includes: In response to the statement type being an insert type, determine whether there is an insert field among the various insert fields included in the target structured statement that matches the sensitive fields included in the configuration file; In response to the confirmation of existence, the matched inserted field is identified as the group of inserted fields to be replaced; Determine whether any of the insertion condition fields included in the target structured statement contain an insertion condition field that matches a sensitive field included in the configuration file; In response to the determination of existence, the matched insertion condition field is identified as the group of insertion condition fields to be replaced; The replacement field table is used to replace the insertion field group and the insertion condition field group in the target structured statement.
7. The method according to claim 6, wherein, The process of replacing the group of fields to be inserted and the group of fields to be inserted in the target structured statement through the replacement field table includes: Select the encrypted field corresponding to each field to be replaced in the group of fields to be replaced from the encrypted field table as the replacement encrypted field to obtain the replacement encrypted field group; Select the index field corresponding to each field to be replaced in the group of fields to be replaced from the index field table as the replacement insertion index field to obtain the replacement insertion index field group; Each replacement insertion encrypted field in the replacement insertion encrypted field group and the corresponding replacement insertion index field in the replacement insertion index field group are combined to generate a combined replacement insertion field, thus obtaining a combined replacement insertion field group. Replace each field to be replaced in the target structured statement with a combined replacement field in the combined replacement field group that corresponds to the field to be replaced. Select the index field corresponding to each insertion condition field to be replaced in the group of insertion condition fields to be replaced from the index field table as the replacement insertion condition index field to obtain the replacement insertion condition index field group; Replace each insert condition field in the target structured statement's insert condition field group with the corresponding insert condition index field in the replace insert condition index field group.
8. The method according to claim 1, wherein, The step of replacing fields in the target structured statement based on the detected statement type and a preset replacement field table includes: In response to the statement type being a deletion type, determine whether there is a deletion condition field among the various deletion condition fields included in the target structured statement that matches the sensitive fields included in the configuration file; In response to the determination of existence, the matched deletion condition field is identified as the group of deletion condition fields to be replaced; The replacement field table is used to replace the group of fields in the target structured statement that are to be deleted.
9. The method according to claim 8, wherein, The process of replacing the group of fields to be replaced or deleted in the target structured statement using the replacement field table includes: Select the index field corresponding to each condition field to be replaced and deleted in the group of condition fields to be replaced and deleted from the index field table as the replacement and deletion index field to obtain the replacement and deletion index field group; Replace each field in the field group to be replaced and deleted in the target structured statement with the corresponding field in the field group to be replaced and deleted in the field group to be replaced and deleted.
10. The method according to claim 1, wherein, The method further includes: Store the encrypted target structured statement.
11. A data encryption device, comprising: The detection unit is configured to detect the statement type of the target structured statement in response to the existence of field table names included in the target structured statement in a preset configuration file; The processing unit is configured to replace fields in the target structured statement according to the detected statement type and a preset replacement field table, wherein the replacement field table includes an encrypted field table and an indexed field table, and the replacement process is performed on the fields in the target structured statement through the following steps: The matched fields are identified as the group of fields to be replaced; Select the encrypted field corresponding to each field to be replaced in the field to be replaced group from the encrypted field table to obtain the replacement encrypted field group; Select the index field corresponding to each field to be replaced in the field to be replaced group from the index field table as the replacement index field to obtain the replacement index field group; Each of the replacement encrypted fields in the replacement encrypted field group and the corresponding replacement index field in the replacement index field group are concatenated to generate a concatenated replacement field, thus obtaining a concatenated replacement field group; Replace each field to be replaced in the field group to be replaced in the target structured statement with the corresponding field to be replaced in the concatenated replacement field group; The encryption unit is configured to encrypt the field value in response to the presence of a corresponding replacement field value in the target structured statement after replacement processing.
12. An electronic device, comprising: One or more processors; A storage device on which one or more programs are stored; When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1-10.
13. A computer-readable medium having a computer program stored thereon, wherein, When the program is executed by the processor, it implements the method as described in any one of claims 1-10.