Data encryption method and device, computer device and storage medium
By reading the metadata of the target service page and the encryption rules of the unified configuration area, the problem of low development efficiency in traditional data encryption is solved, and efficient data encryption processing is achieved.
Patent Information
- Application Number
- CN202310313276.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-20
- Publication Date
- 2026-11-20
- Estimated Expiration
- 2043-03-20
AI Technical Summary
Traditional data encryption technologies suffer from low development efficiency due to the excessive number of page and field matching operations.
By reading the metadata of the target service page, the target data information is determined, the encryption type is obtained, the encryption rules are read from the unified configuration area, the data to be encrypted is encrypted, and the target encrypted data is generated, reducing the number of times page fields are matched with the configuration.
It improves development efficiency, achieves efficient matching between target encryption type and configuration, and reduces the number of times multiple encryption fields are matched with the configuration.
Smart Images

Figure CN116595546B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a data encryption method, apparatus, computer device, and storage medium. Background Technology
[0002] With the continuous development of computer technology, data encryption technology has emerged, which protects the privacy information of private data by encrypting it.
[0003] However, traditional technology achieves encrypted display of fields on the page through configuration. The configuration is loaded into memory when the service starts, and the data is encrypted for the configured pages and fields. This results in too many matching times between the pages and fields and the configuration, which leads to low development efficiency. Summary of the Invention
[0004] Therefore, it is necessary to provide a data encryption method, device, computer equipment, and storage medium that can achieve efficient data encryption to address the above-mentioned technical problems, thereby improving development efficiency.
[0005] A data encryption method, the method comprising:
[0006] Read the metadata corresponding to the target service page to obtain the target metadata;
[0007] Based on the target metadata, determine the target data information corresponding to the target service page;
[0008] Obtain the target encryption type corresponding to the target data information, and determine the data to be encrypted from the target data information based on the target encryption type;
[0009] Based on the target encryption type, read the target encryption rule corresponding to the target encryption type from the unified configuration area;
[0010] The data to be encrypted is encrypted based on the target encryption rule to generate target encrypted data.
[0011] In one embodiment, the target metadata is obtained by reading the metadata corresponding to the target service page, including:
[0012] The system sequentially queries multiple storage areas until it finds the metadata corresponding to the target service page, which is then used as the target metadata.
[0013] The step of determining the target data information corresponding to the target service page based on the target metadata includes:
[0014] The target data information corresponding to the target service page is obtained from the storage area where the target metadata is retrieved.
[0015] In one embodiment, the plurality of storage areas sequentially include a local cache area, a distributed cache area, and a database, or the plurality of storage areas sequentially include a local cache area and a database, or the plurality of storage areas sequentially include a distributed cache area and a database.
[0016] In one embodiment, the unified configuration area includes a distributed cache area and a configuration center area; based on the target encryption type, reading the target encryption rule corresponding to the target encryption type from the unified configuration area includes:
[0017] The target encryption type is queried from the distributed cache to obtain the distribution rule query results;
[0018] When the result of the distribution rule query indicates that the target encryption type exists, the target encryption rule corresponding to the target encryption type is read from the distributed cache based on the target encryption type.
[0019] In one embodiment, the unified configuration area includes a distributed cache area and a configuration center area; based on the target encryption type, reading the target encryption rule corresponding to the target encryption type from the unified configuration area further includes:
[0020] When the distribution rule query result indicates that the target encryption type does not exist, the target encryption type is queried from the target unified configuration file corresponding to the configuration center area to obtain the configuration rule query result;
[0021] Based on the query results of the configuration rules, the target encryption rules corresponding to the target encryption type are read from the target unified configuration file. The encryption rules stored in the target unified configuration file are applicable to at least two different services.
[0022] In one embodiment, the data to be encrypted is a data set of each string to be encrypted corresponding to the target encryption type, and the target encrypted data is a data set of target encrypted strings corresponding to each string to be encrypted; encrypting the data to be encrypted based on the target encryption rule to generate target encrypted data includes:
[0023] Based on the target encryption rule, obtain the forward display count and the last display count;
[0024] Calculate the target total length corresponding to the string to be encrypted, determine the encryption start position based on the forward display number, and determine the encryption end position based on the target total length and the end display number;
[0025] Starting from the encryption start position, read the current character corresponding to the string to be encrypted sequentially, replace the current character with an encryption symbol, until the position of the current character is equal to the encryption end position, and obtain the target encrypted string corresponding to the string to be encrypted.
[0026] In one embodiment, the method further includes:
[0027] Obtain the preset encryption type corresponding to the development service page; based on the preset encryption type, query the database to obtain the preset type query result;
[0028] Obtain the preset metadata corresponding to the development service page, save the preset metadata, and obtain the saving result;
[0029] Based on the preset type query results and the saved results, a preset result notification is generated.
[0030] A data encryption device, the device comprising:
[0031] The metadata reading module is used to read the metadata corresponding to the target service page and obtain the target metadata;
[0032] The data determination module is used to determine the target data information corresponding to the target service page based on the target metadata;
[0033] An encrypted data acquisition module is used to acquire the target encryption type corresponding to the target data information, and determine the data to be encrypted from the target data information based on the target encryption type;
[0034] The rule determination module is used to read the target encryption rule corresponding to the target encryption type from the unified configuration area based on the target encryption type;
[0035] An encryption module is used to encrypt the data to be encrypted based on the target encryption rule, thereby generating target encrypted data.
[0036] A computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program performing the following steps:
[0037] Read the metadata corresponding to the target service page to obtain the target metadata;
[0038] Based on the target metadata, determine the target data information corresponding to the target service page;
[0039] Obtain the target encryption type corresponding to the target data information, and determine the data to be encrypted from the target data information based on the target encryption type;
[0040] Based on the target encryption type, read the target encryption rule corresponding to the target encryption type from the unified configuration area;
[0041] The data to be encrypted is encrypted based on the target encryption rule to generate target encrypted data.
[0042] A computer-readable storage medium having a computer program stored thereon, the computer program performing the following steps when executed by a processor:
[0043] Read the metadata corresponding to the target service page to obtain the target metadata;
[0044] Based on the target metadata, determine the target data information corresponding to the target service page;
[0045] Obtain the target encryption type corresponding to the target data information, and determine the data to be encrypted from the target data information based on the target encryption type;
[0046] Based on the target encryption type, read the target encryption rule corresponding to the target encryption type from the unified configuration area;
[0047] The data to be encrypted is encrypted based on the target encryption rule to generate target encrypted data.
[0048] The aforementioned data encryption method, apparatus, computer equipment, and storage medium obtain target metadata by reading the metadata corresponding to the target service page; determine the target data information corresponding to the target service page based on the target metadata; obtain the target encryption type corresponding to the target data information; determine the data to be encrypted from the target data information based on the target encryption type; read the target encryption rule corresponding to the target encryption type from a unified configuration area based on the target encryption type; and encrypt the data to be encrypted based on the target encryption rule to generate target encrypted data. By reading the target metadata corresponding to the target service page, determining the target data information corresponding to the target service page based on the target metadata, obtaining the target encryption type, determining the data to be encrypted from the target data information based on the target encryption type, and reading the target encryption type corresponding to the target encryption type from the unified configuration area, and finally encrypting the data to be encrypted based on the target encryption type to obtain the corresponding target encrypted data, the method greatly reduces the number of matching operations between page fields and configurations, and achieves matching between the target encryption type and configuration instead of matching multiple encryption fields and configurations, thereby greatly improving development efficiency. Attached Figure Description
[0049] Figure 1 This is a diagram illustrating the application environment of a data encryption method in one embodiment;
[0050] Figure 2 This is a flowchart illustrating a data encryption method in one embodiment;
[0051] Figure 3 This is a schematic diagram of the metadata parsing process in one embodiment;
[0052] Figure 4 This is a schematic diagram of the encryption rule reading process in one embodiment;
[0053] Figure 5 This is a schematic diagram of the encryption rule reading process in another embodiment;
[0054] Figure 6 This is a schematic diagram of the data encryption process in one embodiment;
[0055] Figure 7 This is a schematic diagram of the data pre-setting process in one embodiment;
[0056] Figure 8 This is a schematic diagram of the overall data encryption process in one embodiment;
[0057] Figure 9 This is a timing diagram of pre-set data during the development phase in one embodiment;
[0058] Figure 10 This is a schematic diagram of the data encryption process in another embodiment;
[0059] Figure 11 This is a schematic diagram of the selection interface in one embodiment;
[0060] Figure 12 This is a schematic diagram of an encrypted data display interface in one embodiment;
[0061] Figure 13 This is a structural block diagram of a data encryption device in one embodiment;
[0062] Figure 14 This is an internal structural diagram of a computer device in one embodiment;
[0063] Figure 15 This is a diagram of the internal structure of a computer device in another embodiment. Detailed Implementation
[0064] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0065] The data encryption method provided in this application embodiment can be applied to, for example... Figure 1In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104 or placed on a cloud or other network server. Terminal 102 is used to input and display relevant information about the execution process and receive relevant notification data. Server 104 is used to read the metadata corresponding to the target service page to obtain target metadata; based on the target metadata, determine the target data information corresponding to the target service page; obtain the target encryption type corresponding to the target data information; based on the target encryption type, determine the data to be encrypted from the target data information; based on the target encryption type, read the target encryption rule corresponding to the target encryption type from the unified configuration area; and encrypt the data to be encrypted based on the target encryption rule to generate target encrypted data. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. Server 104 can be implemented using a standalone server or a server cluster composed of multiple servers.
[0066] In one embodiment, such as Figure 2 As shown, a data encryption method is provided, which can be applied to... Figure 1 Taking the server in the example, the following steps are included:
[0067] Step S200: Read the metadata corresponding to the target service page to obtain the target metadata.
[0068] The target service page refers to the page displayed by the currently logged-in microservice. Metadata is information about the organization of data, data domains, and their relationships; it can be data about the data itself or data describing the data. Target metadata refers to the metadata corresponding to the target service page.
[0069] Specifically, users can log in to the corresponding microservices via a browser. Each microservice page has its own unique identifier. Users can log in to multiple microservices simultaneously, and the unique identifier of each page determines the corresponding service page. Once a user enters the target service page, the metadata of that target service page is read to obtain the target metadata. This target metadata describes the data information in the target service page and is used to subsequently retrieve the corresponding data information from the corresponding storage area by parsing this target metadata.
[0070] Step S202: Based on the target metadata, determine the target data information corresponding to the target service page.
[0071] Among them, target data information refers to the data used to render on the target service page, which can be all data information that will be displayed on the target service page.
[0072] Specifically, based on the target metadata that describes the data information corresponding to the target service page, the corresponding target metadata can be queried in the corresponding storage area, and then the data information corresponding to the target service page can be read from the corresponding storage area based on this target metadata. This storage area can be a local cache, a distributed cache, or a database.
[0073] Step S204: Obtain the target encryption type corresponding to the target data information, and determine the data to be encrypted from the target data information based on the target encryption type.
[0074] The target encryption type refers to the data type that needs to be encrypted, which can be a mobile phone number, ID card number, bank card number, etc. The data to be encrypted refers to the data that needs to be encrypted, which can be the data corresponding to a mobile phone number, ID card number, bank card number, etc.
[0075] Specifically, after selecting the corresponding target encryption type on the target service page, data consistent with the target encryption type can be determined from the target data information. For example, if the target encryption type is a mobile phone number, then each piece of data of the mobile phone number type can be determined from the target data information, and the collection of these data is taken as the data to be encrypted. This data to be encrypted needs to be encrypted according to the encryption rules corresponding to the target encryption type, and then the encrypted data is displayed on the corresponding target service page.
[0076] Step S206: Based on the target encryption type, read the target encryption rule corresponding to the target encryption type from the unified configuration area.
[0077] The unified configuration area refers to the area used to cache encryption rules. This can be a distributed buffer or a configuration file in a configuration center, such as ZooKeeper. The target encryption rule refers to the encryption algorithm used to encrypt data. This can be an algorithm commonly used to encrypt mobile phone numbers, ID cards, and bank cards, or an algorithm for dynamic de-identification. For example, a common encryption algorithm for mobile phones is to only display the first 3 and last 4 digits, replacing the rest with asterisks.
[0078] Specifically, to improve system response speed and avoid querying the configuration center for every request sent by the frontend, an intermediate caching scheme was designed. Encryption rules are cached in a distributed buffer using a distributed caching method to improve the efficiency of reading the cache. When it is necessary to read the target encryption rule corresponding to the target encryption type, the system queries the corresponding cache area based on the read cache speed of different areas within the unified configuration area. If the rule for the target encryption type is not found in the faster-reading area, the system then searches the configuration center, where the cache speed is relatively slower.
[0079] Step S208: Encrypt the data to be encrypted based on the target encryption rules to generate the target encrypted data.
[0080] The target encrypted data refers to the data that has already been encrypted.
[0081] Specifically, after reading the corresponding target encryption rule, the data to be encrypted is encrypted according to the encryption method corresponding to the target encryption rule. Different types of target encryption rules can flexibly meet the encryption needs of various scenarios, thereby realizing the dynamic nature of algorithm application. In addition, after encrypting the data to be encrypted according to the encryption method corresponding to the target encryption rule and generating the target encrypted data, the target encrypted data can be sent to the corresponding terminal to realize the display of the encrypted data.
[0082] The aforementioned data encryption method, by obtaining the target service page identifier, determining the target service page based on the identifier, reading the corresponding metadata of the target service page to obtain target metadata, determining the target data information corresponding to the target service page based on the target metadata, obtaining the target encryption type corresponding to the target data information, determining the data to be encrypted from the target data information based on the target encryption type, reading the target encryption rule corresponding to the target encryption type from the unified configuration area based on the target encryption type, and encrypting the data to be encrypted based on the target encryption rule to generate target encrypted data, greatly reduces the number of times page fields are matched with the configuration, and realizes the matching of target encryption type with configuration instead of matching multiple encrypted fields with configuration, thereby greatly improving development efficiency.
[0083] In one embodiment, such as Figure 3 As shown, step S200 includes:
[0084] Step S300: Query multiple storage areas sequentially until the metadata corresponding to the target service page is found, and use it as the target metadata.
[0085] In this context, "storage area" refers to the region used to store data, which can be local cache, distributed cache, or database. Local cache refers to memory based on the local environment. Distributed cache refers to a storage area that stores data using a distributed caching method; this can be a Redis distributed cache. Distributed caching refers to storing frequently used data in a distributed environment or system close to the user and application, preferably on faster devices, to reduce latency in remote data transmission. It is a type of caching in computer applications, typically stored in memory, so that users or applications no longer need to retrieve data from the disk, significantly improving access speed. A database is a repository that organizes, stores, and manages data according to data structures; it is a large collection of organized, shareable, and uniformly managed data stored permanently in a computer.
[0086] Specifically, based on the data access speed priorities of different storage areas, service page-related data can be stored in different regions to achieve data access request responses and improve access efficiency. Local caching offers very fast access speeds; data with low change frequency and low real-time requirements can be stored locally to improve access speed. Furthermore, using local caching reduces data interaction with remote distributed caches like Redis, reducing network I / O overhead and network communication time during data access. Secondly, distributed caches store larger amounts of data compared to local caches and are closer to users and applications, reducing latency in remote data transmission and offering faster access speeds than databases. Therefore, to improve the efficiency of reading cached data during execution and thus improve overall execution efficiency, based on the data access priority of local cache > distributed cache > database, the corresponding data for the target service page can also be stored in both the local cache and the distributed buffer. When the corresponding data is needed, it can be checked in both the local cache and the distributed buffer first, thereby reducing database read pressure and improving data read efficiency.
[0087] Step S202 includes: Step S302, obtaining target data information corresponding to the target service page from the storage area where the target metadata has been queried.
[0088] Specifically, the target metadata storage area can be queried to find the target data information corresponding to the target service page. Based on the target metadata, the target data information of the corresponding target service page can be determined in this storage area. This target data information contains data that needs to be encrypted, which is used to prepare data for subsequent processes.
[0089] In this embodiment, multiple storage areas are queried sequentially until the metadata corresponding to the target service page is found. This metadata is then used as the target data. The target data information corresponding to the target service page is obtained from the storage area where the target metadata is found. This effectively utilizes the response speed priority of different storage areas when parsing metadata. The differences in the fast access to data and the amount of data stored between local cache and distributed cache effectively buffer the problem caused by too many database access requests, thereby speeding up the system response.
[0090] In one embodiment, the multiple storage areas sequentially include a local cache area, a distributed cache area, and a database, or the multiple storage areas sequentially include a local cache area and a database, or the multiple storage areas sequentially include a distributed cache area and a database.
[0091] In one embodiment, such as Figure 4 As shown, step S206 includes:
[0092] Step S400: Query the target encryption type from the distributed cache to obtain the distribution rule query results.
[0093] Among them, the distributed rule query result refers to the result of querying the target encryption type in the distributed buffer.
[0094] Specifically, the distributed buffer may also cache encryption rules corresponding to various encryption types to improve the system's response speed. When the encryption rule corresponding to the target encryption type cached in the distributed buffer is valid, the target encryption type can be queried. When the encryption rule corresponding to the target encryption type cached in the distributed buffer is invalid, the query area must be changed, and the corresponding distributed rule query results are generated based on different query conditions to provide a basis for judgment in the execution of subsequent processes.
[0095] Step S402: When the distributed rule query result indicates the existence of a target encryption type, the target encryption rule corresponding to the target encryption type is read from the distributed cache based on the target encryption type.
[0096] Specifically, when the target encryption type and its corresponding encryption rule cached in the distributed cache have not expired, the corresponding encryption rule is determined in the distributed cache according to the target encryption type, and this encryption rule is used as the target encryption rule. The target encryption rule can be a commonly used encryption algorithm, or it can be a dynamic encryption algorithm that sets various data display positions according to its own needs.
[0097] In this embodiment, by querying the target encryption type from the distributed cache, the distributed rule query result is obtained. When the distributed rule query result indicates that the target encryption type exists, the target encryption rule corresponding to the target encryption type is read from the distributed cache based on the target encryption type. By taking advantage of the characteristic that the data stored in the distributed cache is close to the application, the access speed to the target encryption rule is greatly improved.
[0098] In one embodiment, such as Figure 5 As shown, step S206 further includes:
[0099] Step S500: When the distribution rule query result is that the target encryption type does not exist, query the target encryption type from the target unified configuration file corresponding to the configuration center area to obtain the configuration rule query result.
[0100] The target unified configuration file refers to the configuration file used to store encryption rules or encryption methods corresponding to different encryption types. This target unified configuration file is commonly depended upon by the business logic of each microservice. The configuration rule query result refers to the result obtained by querying the target encryption type in the target unified configuration file.
[0101] Specifically, when the target encryption type is not found in the distributed buffer, it indicates that the target encryption type either does not exist in the distributed cache or its cached form is invalid. In this case, it is necessary to retrieve the target encryption rule corresponding to the target encryption type from the configuration center. The configuration center can be a ZooKeeper distributed configuration center. The unified configuration file for the target encryption type in the configuration center pre-configures encryption rules corresponding to various encryption types. A query can be performed in the unified configuration file based on the target encryption method, generating the corresponding configuration rule query results to provide a basis for subsequent process queries and judgments.
[0102] Step S502: Based on the configuration rule query results, read the target encryption rule corresponding to the target encryption type from the target unified configuration file. The encryption rule stored in the target unified configuration file is applicable to at least two different services.
[0103] Specifically, when the configuration rule query result indicates the existence of the target encryption type, the pre-configured target encryption method can be retrieved from the unified target configuration file based on the target encryption method. Furthermore, the encryption rules stored in this unified target configuration file can be applied to multiple different services. Compared to existing technologies where different services correspond to different configuration files, this approach better ensures that all services take effect synchronously when configuration changes occur, without requiring modifications to the configuration files for each service. This achieves efficient configuration reuse, significantly reduces the workload of operations and maintenance personnel in modifying the configuration center, and avoids errors that can easily occur when modifying multiple sets of configurations simultaneously, thereby improving development efficiency.
[0104] In one embodiment, the encryption rules stored in the target unified configuration file also apply to a service. When only one service depends on the target configuration file, the encryption type corresponding to the service can also be configured with the encryption rules in the target unified configuration file.
[0105] In this embodiment, when the distribution rule query result indicates that the target encryption type does not exist, the target encryption type is queried from the target unified configuration file corresponding to the configuration center area to obtain the configuration rule query result. Based on the configuration rule query result, the target encryption rule corresponding to the target encryption type is read from the target unified configuration file. The encryption rules stored in the target unified configuration file are applicable to different services and implement the configuration of encryption type and encryption rule, which greatly reduces the number of times the configuration is matched, thereby improving the corresponding execution efficiency. In addition, various microservices depend on the same configuration file, which improves the reusability of the configuration and thus improves the development efficiency.
[0106] In one embodiment, such as Figure 6 As shown, step S208 includes:
[0107] Step S600: Based on the target encryption rule, obtain the forward display count and the last display count.
[0108] The forward display count refers to the number of data or characters displayed at the beginning, i.e., the number of unencrypted data or characters at the beginning.
[0109] Specifically, in addition to pre-configured commonly used encryption algorithms / rules, there are also pre-configured encryption rules that can be dynamically changed. A pair of parameters, `start` (number of characters to be displayed before the end) and `end` (number of characters to be displayed after the end), can be maintained in the configuration center. The format is (start, end), indicating that the first `start` and last `end` characters are displayed in plaintext, while the rest are encrypted. For example, if the parameters for a phone number are maintained as (3, 4), it means only the first 3 and last 4 characters are displayed, with the rest encrypted, resulting in 130****5678. If the parameters are changed to (0, 4), the corresponding result is *******5678.
[0110] Step S602: Calculate the target total length corresponding to the string to be encrypted, determine the encryption start position based on the forward display number, and determine the encryption end position based on the target total length and the end display number.
[0111] Here, "strings to be encrypted" refers to the individual strings in the data to be encrypted, which can be, but is not limited to, different mobile phone numbers, different ID card numbers, different bank card numbers, etc. "Target total length" refers to the number of characters in the strings to be encrypted. "Encryption start position" refers to the position corresponding to the first character to be encrypted. "Encryption end position" refers to the position corresponding to the last character to be encrypted, which can be obtained by subtracting the end display number from the target total length.
[0112] Specifically, by determining the positions corresponding to the first and last encrypted characters, the number and position of plaintext characters displayed under different circumstances can be dynamically adjusted according to actual needs. In general code writing, 0 can be used as the first index position of the string. In this embodiment, 1 can be used as the first index position of the string, and the corresponding encryption start and end positions will exactly correspond to the index positions in the string to be encrypted.
[0113] Step S604: Starting from the encryption start position, read the current character corresponding to the string to be encrypted in sequence, replace the current character with an encryption symbol, until the position of the current character is equal to the encryption end position, and obtain the target encrypted string corresponding to the string to be encrypted.
[0114] Here, the encryption symbol refers to a symbol used to replace the original character, which can be *. The target encrypted string refers to the string to be encrypted where the first few characters (corresponding to the number of forward display numbers) and the last few characters (corresponding to the number of backward display numbers) are displayed in plaintext, and the remaining characters are replaced with encryption symbols.
[0115] Specifically, the starting position of the encryption can be used as the index position of the character currently read in the string to be encrypted. The currently read character is then replaced with an encryption symbol to encrypt the character at that position. This process is repeated for each subsequent character, applying the same encryption symbol until the position of the current character equals the end position of the encryption. This indicates that the character to be encrypted in the string has been successfully encrypted, and characters at other positions are displayed in plaintext. Furthermore, existing algorithms can only replace characters of a fixed length in a field with encryption symbols (such as *). For example, a mobile phone number can only process characters 4-7 (e.g., 130****5678). However, the dynamic encryption algorithm in this embodiment can replace characters of any length based on the forward and final display counts of different groups. For example, it could be 130*******8 or 130***45678. Bank cards and ID cards also support replacing characters of any length with *.
[0116] In this embodiment, by obtaining the forward display count and the end display count based on the target encryption rule, the target total length corresponding to the string to be encrypted is calculated. The encryption start position is determined based on the forward display count, and the encryption end position is determined based on the target total length and the end display count. Starting from the encryption start position, the current character corresponding to the string to be encrypted is read sequentially, and the current character is replaced with an encryption symbol until the position of the current character is equal to the encryption end position, thus obtaining the target encrypted string corresponding to the string to be encrypted. This realizes a dynamic encryption algorithm, which allows for selective setting of the number of plaintext data displayed. Compared with existing encryption algorithms that can only perform fixed-length encryption on encrypted fields, the dynamic encryption algorithm is more flexible and conducive to realizing the diversity of dynamic encryption.
[0117] In one embodiment, such as Figure 7 As shown, it also includes:
[0118] Step S700: Obtain the preset encryption type corresponding to the development service page. Based on the preset encryption type, query the database to obtain the preset encryption type query result.
[0119] Here, "development service page" refers to the service page designed by technical personnel during the development phase. "Pre-set encryption type" refers to the types corresponding to various encryption methods, such as mobile phone number, ID card, and bank card. "Pre-set type query results" indicates whether the encryption method corresponding to the encryption type was successfully pre-set.
[0120] Specifically, during the development phase, technical personnel can enable the corresponding encryption button on the development service page to check whether the corresponding encryption type and its corresponding encryption method have been preset during the development phase. At this stage, software technicians can select a preset encryption type on the development service page. The backend server then queries the database based on the preset encryption type to return the corresponding encryption method and generate the corresponding preset type query result. In this embodiment, when querying a preset encryption type, the system returns the preset encryption method, which can be a preset mobile phone number encryption method: the first 3 and last 4 digits are displayed in plaintext, and the rest are displayed as *; a preset ID card encryption method: the first 6 and last 4 digits are displayed in plaintext, and the rest are displayed as *; a preset bank card number encryption method: the last 4 digits are displayed in plaintext, and the rest are displayed as *.
[0121] Step S702: Obtain the preset metadata corresponding to the development service page, save the preset metadata, and obtain the saving result.
[0122] The pre-defined metadata refers to the metadata required for designing and developing the service page. The save result indicates whether the pre-defined metadata was saved successfully.
[0123] Specifically, in order to ensure that users can properly use the service functions of the product when it is officially released to the production environment, the pre-defined metadata of the development service page can be saved. The storage area can be local cache, distributed cache, or database. By utilizing the different characteristics of data access speed and data storage volume of different storage areas, it can help improve the data access efficiency when users use the service. When the pre-defined metadata of the development service page is successfully saved, a saving result containing whether the saving was successful will be generated.
[0124] Step S704: Generate a preset result notification based on the preset type query results and saved results.
[0125] Among them, the preset result notification refers to the notification used to provide technical personnel with a prompt indicating whether the data preset was successful.
[0126] Specifically, once the pre-encrypted queries and pre-defined metadata are saved during the development phase, a pre-defined result notification containing information on whether the operation was successful will be generated. This pre-defined result notification can be sent to the target terminal corresponding to the development service page, allowing technical personnel to view the information in the pre-defined result notification and know that the corresponding operation has been completed. If a problem occurs during the corresponding operation, the pre-defined result notification will also include information about the problem, so that technical personnel can resolve the corresponding problem based on the problem information.
[0127] In this embodiment, by obtaining the preset encryption type corresponding to the development service page, querying the preset encryption type from the database based on the preset encryption type, obtaining the preset type query result, obtaining the preset metadata corresponding to the development service page, saving the preset metadata, obtaining the saving result, and generating a preset result notification based on the preset type query result and the saving result, the system realizes the query of encryption methods and the saving of preset metadata during the development stage, which is beneficial to improving the access speed of the data corresponding to the service page.
[0128] In one embodiment, the various business microservices corresponding to the webapp product can be used as services that users can log into. Figure 8 This is a general diagram illustrating the approach for software developers to encrypt data corresponding to various business microservices when using the product. Figure 8In this framework, webapp serves as the front-end service, SCM as the inventory management service, BD as the basic data service, and LS as the retail service. The inventory management service, also known as the supply chain service, refers to the dynamic management process of purchasing (inbound) -> warehousing (inventory) -> sales (outbound) in enterprise management. The basic data service mainly provides and maintains basic data used for business operations, such as customer information, product information, and employee information. This basic data contains fields that require encryption. The retail service refers to the service of selling small quantities of goods directly to consumers from a single point (shopping mall, market, department store, etc.) for their final use. Besides... Figure 8 In addition to the business microservices shown, other types of business microservices are available for user applications, and each microservice contains corresponding data that needs to be encrypted. Users can log in to multiple different services corresponding to the product via a browser, and initiate a request to view private data (such as a phone number) on the corresponding service page. Then, the BOS engine parses the metadata of the corresponding service page, retrieves the corresponding data information from the local cache, distributed cache, or database based on the metadata, and then reads the corresponding encryption rule from the configuration center ZooKeeper according to the encryption type of the private data. Based on this encryption rule, the data corresponding to the fields requiring encryption in the parsed data is encrypted, resulting in encrypted data. This encrypted data is then presented on the corresponding service page, thus achieving efficient encryption of private data. Figure 9 This is a sequence diagram for software developers to query encryption methods and store service page metadata during the development phase. Figure 9 BOS Designer is a browser-based graphical form design tool that helps software developers quickly design pages of various styles.
[0129] In one embodiment, such as Figure 10 As shown, Figure 10This document demonstrates the entire process from a user entering the web interface to the final encrypted data display. Furthermore, a single user can simultaneously access multiple business microservices corresponding to the product. These microservices rely on the same configuration file storing encryption rules. Once the encryption type matches the configuration, the data requiring encryption in the service pages of different business microservices can be encrypted according to the encryption rules configured for that type. Specifically, the process involves: identifying the target service page based on its identifier; reading the corresponding metadata to obtain the target metadata; determining the target data information corresponding to the target service page based on the target metadata; obtaining the target encryption type corresponding to the target data information; determining the data to be encrypted based on the target encryption type; reading the target encryption rules corresponding to the target encryption type from the unified configuration area based on the target encryption type; encrypting the data to be encrypted based on the target encryption rules; generating the target encrypted data; and presenting the target encrypted data to the corresponding terminal. This achieves one-click support for encrypted display of sensitive fields with zero-code, lightweight configuration. Among them, zero-code refers to the ability for users to quickly build applications without programming. Through abstraction, encapsulation, and integration, it enables users to achieve certain functions through simple operations (such as enabling parameters); lightweight configuration refers to reducing the configuration parameters on the product server side and meeting common anonymization scenarios through pre-built solutions; the unified configuration area includes... Figure 10 Distributed caching and configuration center in the middle, Figure 10 In this context, data anonymization is equivalent to encryption, and the rules for data anonymization are essentially encryption rules. Data anonymization, also known as data encryption, refers to the process of transforming sensitive information according to certain rules to reliably protect sensitive and private data. Figure 11 and Figure 12 For the interface display of the service page corresponding to the product, from Figure 11 It is known that different encryption types can be selected (such as mobile phone number, bank card, and ID card), from Figure 12 It is evident that different encryption types require different encryption methods, thus meeting the encryption needs of diverse scenarios. Meeting these diverse encryption requirements improves the user experience and also enhances the execution efficiency of various business microservices. Based on the priority of local cache > Redis distributed cache > database caching efficiency, the issue of relatively frequent metadata parsing using the high-performance Java local caching component Caffeine Cache is avoided, thereby improving data access speed. Furthermore, by having multiple business microservices rely on the same configuration file, only the encryption type needs to be matched with the configuration, alleviating the pressure of existing technologies where multiple fields on multiple pages need to be matched with the configuration before encryption can be performed, significantly improving development efficiency.
[0130] Based on the same inventive concept, this application also provides a data encryption device for implementing the data encryption method described above. The solution provided by this device is similar to the implementation described in the above method; therefore, the specific limitations in one or more data encryption device embodiments provided below can be found in the limitations of the data encryption method described above, and will not be repeated here.
[0131] In one embodiment, such as Figure 13 As shown, a data encryption device is provided, including: a metadata reading module 1300, a data determination module 1302, an encrypted data acquisition module 1304, a rule determination module 1306, and an encryption module 1308, wherein:
[0132] The metadata reading module 1300 is used to read the metadata corresponding to the target service page and obtain the target metadata.
[0133] The data determination module 1302 is used to determine the target data information corresponding to the target service page based on the target metadata.
[0134] The encrypted data acquisition module 1304 is used to acquire the target encryption type corresponding to the target data information, and determine the data to be encrypted from the target data information based on the target encryption type.
[0135] The rule determination module 1306 is used to read the target encryption rule corresponding to the target encryption type from the unified configuration area based on the target encryption type.
[0136] The encryption module 1308 is used to encrypt the data to be encrypted based on the target encryption rule to generate target encrypted data.
[0137] In one embodiment, the data determination module 1300 is further configured to sequentially query multiple storage areas until the metadata corresponding to the target service page is found, which is then used as the target metadata. The multiple storage areas sequentially include a local cache, a distributed cache, and a database, or the multiple storage areas sequentially include a local cache and a database, or the multiple storage areas sequentially include a distributed cache and a database.
[0138] In one embodiment, the data determination module 1302 is further configured to obtain target data information corresponding to the target service page from the storage area where the target metadata is queried.
[0139] In one embodiment, the rule determination module 1306 is further configured to query the target encryption type from the distributed cache to obtain a distributed rule query result; when the distributed rule query result indicates that the target encryption type exists, the target encryption rule corresponding to the target encryption type is read from the distributed cache based on the target encryption type.
[0140] In one embodiment, the rule determination module 1306 is further configured to, when the distribution rule query result indicates that the target encryption type does not exist, query the target encryption type from the target unified configuration file corresponding to the configuration center area to obtain the configuration rule query result; based on the configuration rule query result, read the target encryption rule corresponding to the target encryption type from the target unified configuration file, wherein the encryption rule stored in the target unified configuration file is applicable to at least two different services.
[0141] In one embodiment, the encryption module 1308 is further configured to: obtain the forward display count and the end display count based on the target encryption rule; calculate the target total length corresponding to the string to be encrypted; determine the encryption start position based on the forward display count; determine the encryption end position based on the target total length and the end display count; sequentially read the current character corresponding to the string to be encrypted starting from the encryption start position; replace the current character with an encryption symbol until the position of the current character is equal to the encryption end position, thereby obtaining the target encrypted string corresponding to the string to be encrypted.
[0142] In one embodiment, the data encryption device further includes a preset module 1310, which is used to obtain a preset encryption type corresponding to the development service page, query the preset encryption type from the database based on the preset encryption type to obtain a preset type query result; obtain preset metadata corresponding to the development service page, save the preset metadata to obtain a save result; and generate a preset result notification based on the preset type query result and the save result.
[0143] Each module in the aforementioned data encryption device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0144] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 14As shown, this computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores data related to different types of services. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When executed by the processor, the computer program implements a data encryption method.
[0145] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 15 As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a data encryption method. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.
[0146] Those skilled in the art will understand that Figure 14 and Figure 15The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0147] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method examples.
[0148] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps in the above method embodiments.
[0149] In one embodiment, a computer program product or computer program is provided, the computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and executes the computer instructions, causing the computer device to perform the steps in the above method embodiments.
[0150] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0151] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0152] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0153] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A data encryption method, characterized in that, The method includes: Based on the priority of data access speed in the storage areas, the data related to the service page is stored in different storage areas. Multiple storage areas are queried sequentially until the metadata corresponding to the target service page is found, which is then used as the target metadata. The multiple storage areas include a local cache, a distributed cache, and a database. Obtain the target data information corresponding to the target service page from the storage area where the target metadata is retrieved; Obtain the target encryption type corresponding to the target data information, and determine the data to be encrypted from the target data information based on the target encryption type; Based on the target encryption type, read the target encryption rule corresponding to the target encryption type from the unified configuration area; The data to be encrypted is encrypted based on the target encryption rule to generate target encrypted data; The unified configuration area includes a distributed cache area and a configuration center area; the step of reading the target encryption rule corresponding to the target encryption type from the unified configuration area based on the target encryption type includes: querying the target encryption type from the distributed cache area to obtain the distributed rule query result; When the result of the distribution rule query indicates that the target encryption type exists, the target encryption rule corresponding to the target encryption type is read from the distributed cache based on the target encryption type. When the distribution rule query result indicates that the target encryption type does not exist, the target encryption type is queried from the target unified configuration file corresponding to the configuration center area to obtain the configuration rule query result; based on the configuration rule query result, the target encryption rule corresponding to the target encryption type is read from the target unified configuration file, and the encryption rule stored in the target unified configuration file is applicable to at least two different services.
2. The method according to claim 1, characterized in that, The data to be encrypted is a data set of each string to be encrypted corresponding to the target encryption type, and the target encryption data is a data set of the target encryption strings corresponding to each string to be encrypted; The step of encrypting the data to be encrypted based on the target encryption rule to generate target encrypted data includes: Based on the target encryption rule, obtain the forward display count and the last display count; Calculate the target total length corresponding to the string to be encrypted, determine the encryption start position based on the forward display number, and determine the encryption end position based on the target total length and the end display number; Starting from the encryption start position, read the current character corresponding to the string to be encrypted sequentially, replace the current character with an encryption symbol, until the position of the current character is equal to the encryption end position, and obtain the target encrypted string corresponding to the string to be encrypted.
3. The method according to claim 1, characterized in that, The method further includes: Obtain the preset encryption type corresponding to the development service page; based on the preset encryption type, query the database to obtain the preset type query result; Obtain the preset metadata corresponding to the development service page, save the preset metadata, and obtain the saving result; Based on the preset type query results and the saved results, a preset result notification is generated.
4. The method according to claim 3, characterized in that, The preset result notification is used to provide technical personnel with a notification indicating whether the data preset was successful.
5. A data encryption device for performing the method as described in claim 1, characterized in that, The device includes: The metadata reading module is used to query multiple storage areas sequentially until the metadata corresponding to the target service page is found, which is then used as the target metadata; the multiple storage areas include a local cache, a distributed cache, and a database in sequence; The data determination module is used to obtain target data information corresponding to the target service page from the storage area where the target metadata is queried; An encrypted data acquisition module is used to acquire the target encryption type corresponding to the target data information, and determine the data to be encrypted from the target data information based on the target encryption type; The rule determination module is used to read the target encryption rule corresponding to the target encryption type from a unified configuration area based on the target encryption type. The unified configuration area includes a distributed cache area and a configuration center area. Specifically, it includes: querying the target encryption type from the distributed cache area to obtain a distributed rule query result; when the distributed rule query result indicates that the target encryption type exists, reading the target encryption rule corresponding to the target encryption type from the distributed cache area based on the target encryption type; when the distributed rule query result indicates that the target encryption type does not exist, querying the target encryption type from the target unified configuration file corresponding to the configuration center area to obtain a configuration rule query result; and reading the target encryption rule corresponding to the target encryption type from the target unified configuration file based on the configuration rule query result. The encryption rules stored in the target unified configuration file are applicable to at least two different services. An encryption module is used to encrypt the data to be encrypted based on the target encryption rule, thereby generating target encrypted data.
6. The apparatus according to claim 5, characterized in that, The data to be encrypted is a data set of each string to be encrypted corresponding to the target encryption type, and the target encrypted data is a data set of target encrypted strings corresponding to each string to be encrypted. The encryption module is further configured to: obtain the forward display count and the end display count based on the target encryption rule; calculate the target total length corresponding to the string to be encrypted, determine the encryption start position based on the forward display count, and determine the encryption end position based on the target total length and the end display count; sequentially read the current character corresponding to the string to be encrypted starting from the encryption start position, replace the current character with an encryption symbol, until the position of the current character is equal to the encryption end position, and obtain the target encrypted string corresponding to the string to be encrypted.
7. The apparatus according to claim 5, characterized in that, The data encryption device is also used to: obtain a preset encryption type corresponding to the development service page, and query the preset encryption type from the database based on the preset encryption type to obtain the preset type query result; Obtain the preset metadata corresponding to the development service page, save the preset metadata, and obtain the saving result; Based on the preset type query results and the saved results, a preset result notification is generated.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 4.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 4.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Information access method, apparatus, electronic device, and computer-readable storage medium
CN109472156A
Systems and methods of database encryption in a multi-tenant database management system
CN112889054A
Log desensitization method and device
CN114707180A
