Data encryption method and device, computer equipment and storage medium
By dividing the plaintext data into the first and second data and encrypting them respectively, and using the location identification data to generate the third encrypted data, the problems of low efficiency and insufficient security in encryption and decryption of large amounts of data are solved, and efficient and secure data encryption is achieved.
Patent Information
- Application Number
- CN202510344560.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-18
- Publication Date
- 2025-09-23
AI Technical Summary
Existing technologies are inefficient and insecure when it comes to encrypting and decrypting large amounts of data. In particular, when the encryption method is cracked, the original content is easily leaked, and the encrypted data storage takes up a large amount of space.
The plaintext data is divided into first data that meets the preset conditions and second data that does not meet the preset conditions, the first data and the second data are encrypted respectively, and the third encrypted data is generated using the position identification data. The third encrypted data corresponding to the plaintext data is generated by replacing the first data with the preset position identification data and combining the first encrypted data and the second encrypted data.
It improves the efficiency and security of data encryption, reduces data storage space, increases the difficulty of data cracking, and ensures that the plaintext data can only be restored by obtaining two parts of encrypted data at the same time.
Smart Images

Figure CN120688068A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a data encryption method, apparatus, computer equipment, and storage medium. Background Art
[0002] Data encryption and decryption is a crucial aspect of information security. It involves converting plaintext into ciphertext and back again. In many industries, sensitive or confidential data must be encrypted before transmission during data exchange. The recipient then processes the encrypted data according to pre-defined encryption and decryption rules, obtaining the decrypted data and performing the corresponding data processing.
[0003] Therefore, how to encrypt data in the field of data processing has become one of the hot issues in current research. Summary of the Invention
[0004] In response to the above technical problems, embodiments of the present application provide a data encryption method, apparatus, computer device, and storage medium.
[0005] In a first aspect, an embodiment of the present application provides a data encryption method, comprising:
[0006] Determining first data and second data in the plaintext data, where the first data refers to data in the plaintext data that meets a preset condition, and the second data refers to data in the plaintext data that does not meet the preset condition;
[0007] Replacing the first data with preset location identification data, and determining first encrypted data based on the location identification data and the first data;
[0008] encrypting the second data to obtain second encrypted data;
[0009] The location identification data, the first encrypted data, and the second encrypted data are concatenated to obtain third encrypted data corresponding to the plaintext data.
[0010] In a second aspect, an embodiment of the present application provides a data encryption device, comprising:
[0011] a first determining module, configured to determine first data and second data in the plaintext data, wherein the first data refers to data in the plaintext data that meets a preset condition, and the second data refers to data in the plaintext data that does not meet the preset condition;
[0012] a first encryption module, configured to replace the first data with preset location identification data, and determine first encrypted data based on the location identification data and the first data;
[0013] a second encryption module, configured to encrypt the second data to obtain second encrypted data;
[0014] The second determining module is configured to combine the location identification data, the first encrypted data, and the second encrypted data to obtain third encrypted data corresponding to the plaintext data.
[0015] In a third aspect, an embodiment of the present application further provides a computer device, comprising a memory storing a plurality of instructions; a processor loading instructions from the memory to execute the steps of any one of the data encryption methods provided in the embodiment of the present application.
[0016] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, which stores a plurality of instructions suitable for loading by a processor to execute the steps of any data encryption method provided in an embodiment of the present application.
[0017] In a fifth aspect, an embodiment of the present application further provides a computer program product, comprising a computer program or instructions, which, when executed by a processor, implements the steps of any one of the data encryption methods provided in the embodiments of the present application.
[0018] The solution of the embodiment of the application is adopted. By dividing the plaintext data into first data that meets the preset conditions and second data that does not meet the preset conditions, the first data in the plaintext data is replaced with preset location identification data. After the first data and the second data are encrypted to obtain the first encrypted data and the second encrypted data respectively, the location identification data, the first encrypted data and the second encrypted data are combined to determine the third encrypted data corresponding to the plaintext data. On the one hand, the application divides the plaintext data into first data and second data according to the preset conditions and encrypts them separately, rather than directly encrypting the plaintext data, providing a personalized encryption method that can improve the security of data encryption to a certain extent. On the other hand, the application also uses location identification data, combined with the first encrypted data and the second encrypted data to generate the third encrypted data corresponding to the plaintext data, which increases the complexity of the encrypted data and greatly improves data security. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0020] Figure 1Schematic diagram of the application environment of the data encryption method or data decryption method provided in the embodiments of the present application;
[0021] Figure 2 This is a schematic diagram of a first flow chart of an embodiment of a data encryption method provided in an embodiment of the present application;
[0022] Figure 3 This is a second flow chart of an embodiment of the data encryption method provided in the embodiments of the present application;
[0023] Figure 4 This is a third flow chart of an embodiment of the data encryption method provided in the embodiments of the present application;
[0024] Figure 5 This is a fourth flow chart of an embodiment of the data encryption method provided in the embodiments of the present application;
[0025] Figure 6 This is a fifth flow chart of an embodiment of the data encryption method provided in the embodiments of the present application;
[0026] Figure 7 This is a sixth flow chart of an embodiment of the data encryption method provided in the embodiments of the present application;
[0027] Figure 8 This is a seventh flow chart of an embodiment of the data encryption method provided in the embodiments of the present application;
[0028] Figure 9 is a schematic structural diagram of a data encryption device provided in an embodiment of the present application;
[0029] Figure 10 It is a schematic diagram of the internal structure of the computer device provided in the embodiment of the present application. DETAILED DESCRIPTION
[0030] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of this application. At the same time, in the description of the embodiments of the present application, the terms "first", "second", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more features. In the description of the embodiments of the present application, the meaning of "multiple" is two or more, unless otherwise clearly and specifically defined.
[0031] In one embodiment of the present application, the data encryption method and the data decryption method can be run on a local terminal device or a server.
[0032] In order to better understand the data encryption method, data decryption method, device, electronic device and storage medium provided in the embodiments of the present application, the application environment applicable to the embodiments of the present application is described below.
[0033] See also Figure 1 , Figure 1 The following is a schematic diagram showing an application environment of the data encryption method provided by an embodiment of the present application. As an implementation method, the data encryption method provided by the embodiment of the present application can be applied to the same electronic device (or computer device). The electronic device can be Figure 1 The server 110 shown in FIG. 1 can be connected to the terminal device 120 via a network. The network is used to provide a medium for a communication link between the server 110 and the terminal device 120. The network can include various connection types, such as wired communication links, wireless communication links, etc., which are not limited in the embodiments of the present application. Alternatively, in other embodiments, the electronic device can also be a smartphone, a laptop computer, etc.
[0034] It should be understood that Figure 1 The server 110, network, and terminal device 120 are merely illustrative. Any number of servers, networks, and terminal devices may be provided as needed. For example, the server 110 may be a physical server or a server cluster consisting of multiple servers, and the terminal device 120 may be a mobile phone, tablet, desktop computer, laptop computer, or the like. It will be appreciated that embodiments of the present application may also allow multiple terminal devices 120 to access the server 110 simultaneously.
[0035] In some embodiments, the terminal device 120 can obtain plaintext input by the user. Further, the terminal device 120 sends the plaintext to the server 110 through the network. After the server 110 receives the plaintext, it can process the plaintext using the data encryption method described in the embodiments of the present application.
[0036] The following is a detailed description of each step in conjunction with the accompanying drawings. In this embodiment, a terminal device is used as an example. It should be noted that the order in which the following embodiments are described does not limit the preferred order of the embodiments. Although the flowcharts illustrate a logical order, in some cases, the steps shown or described may be performed in a different order than that shown in the accompanying drawings.
[0037] Traditional encryption methods directly encrypt plaintext data. However, when faced with large amounts of data, encryption and decryption efficiency is very low. Furthermore, once the encryption method is cracked, the original content will be leaked, resulting in a low security factor. Furthermore, when the data volume is large, the encrypted data will occupy a large amount of memory when stored.
[0038] Because, in order to solve at least the above-mentioned problems, the embodiments of the present application propose a data processing data encryption method, device, computer equipment and storage medium. By extracting the first data that meets the preset conditions and the second data that does not meet the preset conditions from the plaintext data, and encrypting the first data and the second data respectively, the same first data only needs to be encrypted once, which effectively improves the encryption efficiency. In addition, by replacing the first data with preset location identification data, the amount of plaintext data is reduced, further improving the encryption efficiency and reducing the space occupied by data storage. In addition, in the present application, the plaintext data can only be restored after the first encrypted data and the second encrypted data are obtained at the same time. Only when both parts of the encrypted data are cracked can the original plaintext data be restored, thereby increasing the security of the data.
[0039] Specifically, the data encryption method in the embodiment of the present application is as follows: Figure 2 As shown, this may include:
[0040] S10, determining first data and second data in the plaintext data, where the first data refers to data in the plaintext data that meets a preset condition, and the second data refers to data in the plaintext data that does not meet the preset condition;
[0041] In this embodiment, the user may initiate a data processing request (encryption storage request or decryption data acquisition request).
[0042] The terminal device can respond to the data processing request, and when it detects that the data processing request is an encrypted storage request, it can determine the first data and the second data in the plaintext data through data retrieval, wherein the first data in this embodiment refers to the data in the plaintext data that meets the preset conditions, and the second data refers to the data in the plaintext data that does not meet the preset conditions, wherein the preset conditions in this embodiment can specifically be that the number of occurrences is greater than or equal to two times, which will be described in detail in subsequent embodiments and will not be repeated here.
[0043] The plaintext data in this embodiment may be data to be encrypted, such as text to be encrypted, etc. The subsequent embodiments will be described using the plaintext data being English text to be encrypted as an example.
[0044] S20, replacing the first data with preset location identification data, and determining first encrypted data based on the location identification data and the first data;
[0045] After determining the first data and the second data in the plaintext data, the terminal device may replace the first data in the plaintext data with the location identification data.
[0046] It should be noted that, in this embodiment, the position identification data can be used to indicate the position of the first data in the plaintext data.
[0047] For example, for the plaintext data "consumption, boredom, grade, gradual, name, boost", since "bo" appears twice, the data "bo" can be used as the first data. In this way, the above plaintext data can include the first data "bo" and the first data "grad". In one embodiment, in order to restore the first data to the corresponding position in the plaintext data, it is necessary to associate the first data with the corresponding position identification data, that is, "-bo" and "+grad". Then, the first data "bo" in the plaintext data can be replaced with the corresponding position identification data "-", and the first data "grad" can be replaced with the position identification data "+". At this time, the plaintext data can be "consumption, -redom, +e, +ual, name, -ost", and the second data corresponds to "consumption, redom, e, ual, name, ost". It can be seen that the position identification data "-" represents the position of "bo" in the plaintext data, and the position identification data "+" represents the position of "grad" in the plaintext data.
[0048] Thus, in this embodiment, by replacing the same data in the plaintext data with the corresponding identification data, the amount of data to be encrypted and the storage space can be reduced. Moreover, since it is necessary to determine the data represented by the position identification data in order to restore the plaintext data, this embodiment also increases the difficulty of data cracking and improves data security.
[0049] It is worth noting that in this embodiment, the first data may include at least two characters. Taking the plaintext data as English text as an example, the first data may refer to a set of letters consisting of the same and consecutive letters in multiple words (the number of the same letters needs to be greater than or equal to 2, and the specific number needs to be determined by the specific word). It can be in any part of the word, as long as it is composed of consecutive identical letters. For example, name and game have the same first data "ame". For another example, there is only a single identical letter "a" between "name" and "grade", and "a" cannot be used as the first data.
[0050] Furthermore, this embodiment can determine the first encrypted data based on the location identification data and the first data.
[0051] For example, this embodiment can shuffle the first data to disrupt the order of at least two characters in the first data, replace the shuffled first data with a preset identifier, and then associate the identifier with the above-mentioned position identifier data to obtain the first encrypted data.
[0052] It can be understood that in this embodiment, since the same multiple groups of first data have been extracted from the plaintext data in advance, the terminal device can directly perform encryption processing on any one of the same multiple groups of first data, without having to encrypt each of the same groups of first data. For example, if the first data is "bo", then the terminal device only needs to encrypt "bo" once, without having to encrypt the "bo" in "boredom" and "boost" one by one. Through this encryption method, this embodiment can significantly improve the encryption efficiency.
[0053] S30, encrypting the second data to obtain second encrypted data;
[0054] In this embodiment, after extracting the first data and the second data from the plaintext data, the terminal device may encrypt the first data to obtain first encrypted data, and encrypt the second data to obtain second encrypted data.
[0055] For example, combined with the above description, for the plaintext data "consumption,boredom,grade,gradual,name,boost", when the first data can be "bo" and "grad", the second data at this time can be "consumption,redom,e,ual,name,ost". At this time, the terminal device can encrypt the first data "bo" and "grad" respectively to obtain the corresponding first encrypted data, and encrypt the second data "consumption,redom,e,ual,name,ost" to obtain the corresponding second encrypted data.
[0056] S40: Concatenate the location identification data, the first encrypted data, and the second encrypted data to obtain third encrypted data corresponding to the plaintext data.
[0057] In this embodiment, after the terminal device encrypts the first data to obtain the first encrypted data, and encrypts the second data to obtain the second encrypted data, it can generate the third encrypted data corresponding to the above-mentioned plaintext data based on the above-mentioned location identification data, the first encrypted data and the second encrypted data.
[0058] For example, in this embodiment, the terminal device can concatenate the location identification data, the first encrypted data and the second encrypted data to generate third encrypted data corresponding to the plaintext data, wherein the third encrypted data at least includes the location identification data, the first encrypted data and the second encrypted data.
[0059] Therefore, in an embodiment of the present application, the terminal device can obtain first data that meets the preset conditions and second data that does not meet the preset conditions in the plaintext data, and replace the first data with the preset location identifier data. Furthermore, the terminal device can encrypt the first data to obtain first encrypted data, encrypt the second data to obtain second encrypted data, and concatenate the location identifier data, the first encrypted data, and the second encrypted data to obtain third encrypted data corresponding to the plaintext data.
[0060] It can be seen that compared with the prior art of directly encrypting plaintext data, the embodiment of the present application can divide the plaintext data into first data and second data, so that the first data can be replaced with preset location identification data, and after the first data and the second data are encrypted respectively to obtain the first encrypted data and the second encrypted data, the encrypted data is determined in combination with the location identification data. On the one hand, the present application improves the data encryption processing efficiency by dividing the plaintext data into first data and second data and processing them separately, without the need to encrypt the data in the plaintext data one by one; on the other hand, the present application also uses location identification data, and combines the first encrypted data and the second encrypted data to generate encrypted data. Since only the data represented by the cracked location identification data can be decrypted, the present application also greatly improves data security.
[0061] In one embodiment, in the above S40, "the location identification data, the first encrypted data and the second encrypted data are concatenated to obtain the third encrypted data corresponding to the plaintext data", such as Figure 3 As shown, this may include:
[0062] S401, determining an encryption identifier according to an identifier corresponding to a target random number;
[0063] S402: Arrange and concatenate the position identification data, the first encrypted data, the second encrypted data, and the encryption identifier according to a preset arrangement rule to obtain third encrypted data corresponding to the plaintext data.
[0064] It should be noted that, in this embodiment, encrypting the first data and the second data may at least involve: scrambling the first data and the second data respectively to disrupt the order of characters in the data, increase the complexity of data encryption, and encrypting the scrambled data according to the encryption algorithm, replacing special characters, and other operations. It can be understood that, in this embodiment, operations such as scrambling, encrypting, and replacing special characters on data can all be used as encryption operations (that is, the encryption operations in this embodiment are not limited to encrypting data using an encryption algorithm, but also include operations such as scrambling and replacing special characters).
[0065] Moreover, in this embodiment, the encryption identifier can be determined based on the identifier corresponding to the target random number, such as replacing the target random number with a preset identifier to obtain the encryption identifier. For example, before each encryption, the terminal device can randomly generate a value n from the numerical interval [x, y] as the target random number, and then replace the target random number n with a preset identifier to obtain the encryption identifier. For example, in this embodiment, the encryption identifier can be a special character, such as "*", and this embodiment does not specifically limit the type of identifier. In addition, in this embodiment, the identifier corresponding to the target random number can also be stored in association with the target random number, so that the identifier can be restored to the corresponding target random number after subsequent decryption. The subsequent embodiments will be described in detail and will not be repeated here.
[0066] Furthermore, the terminal device can select the exchange position for data exchange based on the random number n value and perform shuffling on the data. For example, if the first data and the second data are words, then for each word, the n value can be modulo operation according to the position value of the character in the word in turn to obtain the modulo value corresponding to each character (it can be understood that the position identification data such as "+", "-", etc. do not participate in the encryption process during the calculation process), and then the word can be shuffled according to the modulo value of each character in the word and the n value. It is worth noting that the shuffling rule can be generated by the user or automatically by the terminal device, which will be explained in detail in subsequent embodiments.
[0067] Furthermore, the terminal device may concatenate the position identification data, the first encrypted data, the second encrypted data and the encryption identifier according to a preset arrangement rule to generate third encrypted data corresponding to the plaintext data.
[0068] It should be noted that, in this embodiment, the preset arrangement rule can be customized by the user or generated by the terminal device. The preset arrangement rule can be used to indicate the sorting method and / or combination method of the above-mentioned location identification data, first encrypted data, second encrypted data and first identification. The preset arrangement rule can be stored in the system program so that the preset arrangement rule can be used for encryption later.
[0069] For example, in one embodiment, the location identification data and the first encrypted data may be associated first, and then the second encrypted data, the first identification, the associated location identification data and the first encrypted data may be concatenated to obtain third encrypted data corresponding to the plaintext data.
[0070] Therefore, compared with the prior art of directly encrypting plaintext data, the form of the generated encrypted data is relatively simple. In the embodiment of the present application, since the first data and the second data are encrypted separately, and the first data is replaced by the location identification data, the target random number for encrypting the first data and the second data is replaced by the encryption identifier, the type of the generated encrypted data is enriched, so that when decrypting, not only the decryption rules need to be obtained, but also the data represented by the location identification data and the encryption identifier need to be obtained, which significantly increases the difficulty of decryption and improves the security of the plaintext data.
[0071] In one embodiment, the preset condition includes the number of occurrences being greater than or equal to two times. In the above S10, “determining the first data and the second data in the plaintext data”, for example Figure 4 As shown, the following steps may be included:
[0072] S101, dividing the characters in the plaintext data according to the types of the characters in the plaintext data to obtain a plurality of character sequences, each character sequence including at least two characters of different types;
[0073] S102, determining identical character sequences among the multiple character sequences, and determining data composed of characters in the identical character sequences as first data; the number of the identical character sequences is at least two;
[0074] S103: Determine the data in the plaintext data that does not belong to the first data as the second data.
[0075] It should be noted that, in this embodiment, taking the plaintext data as English characters as an example, the types of characters in the plaintext data can be understood as different characters, such as "a", "b", and "c" are all different types of characters.
[0076] Furthermore, the terminal device can divide the characters in the plaintext data according to the types of characters in the plaintext data to obtain multiple character sequences, determine the same character sequence in the multiple character sequences, and determine the data composed of the characters in the same character sequence as the first data.
[0077] For example, for the plaintext data "consumption, boredom, grade, gradual, name, boost", the characters in the plaintext data are divided according to the type of characters in the plaintext data, and multiple character sequences "bo", "bo", "grad", and "grad" are obtained. That is, the character sequence "bo" exists in both "boredom" and "boost", and the character sequence "grad" exists in both "grade" and "gradual".
[0078] Furthermore, the data "bo" composed of the same character sequence "bo" can be used as the first data, and the data "grad" composed of the same character sequence "grad" can also be used as the first data of another category.
[0079] Furthermore, the plaintext data that does not belong to the first data can be determined as the second data. For example, for the plaintext data "consumption, boredom, grade, gradual, name, boost", when the first data is "bo" and "grad", the second data is "consumption, redom, e,ual, name, ost".
[0080] In one embodiment, if Figure 5 As shown, in the above S20, "determining first encrypted data according to the location identification data and the first data" may include:
[0081] S201, performing out-of-order processing on the first data;
[0082] S202: Concatenate the location identification data with the first data after shuffling to obtain first encrypted data.
[0083] In this embodiment, combined with the above description, for the plaintext data "consumption, boredom, grade, gradual, name, boost", since the data "bo" exists in both "boredom" and "boost", "bo" can be used as the first data, and the character sequence "grad" exists in both "grade" and "gradual", so "grad" can be used as another first data.
[0084] Furthermore, in this embodiment, the terminal device may perform shuffling on the first data, and associate the shuffled first data with the location identification data to obtain first encrypted data.
[0085] For example, for the plaintext data "consumption, boredom, grade, gradual, name, boost", when the first data is "bo" and the position identification data is "-", the disordered first data can be associated with the position identification data "-" to obtain the first encrypted data.
[0086] As for the first data "grad" of another category, the first data "grad" can be associated with the position identification data "+" to obtain the corresponding first encrypted data.
[0087] In this way, when encrypting the first data of each category, the terminal device can shuffle the characters in the first data, replace the shuffled plaintext data with a preset first identifier, and associate the first identifier with the location identifier data to obtain the first encrypted data.
[0088] Therefore, in this embodiment, all identical data in the plaintext data can be extracted, and the identical data only needs to be encrypted once, effectively improving encryption efficiency. This also reduces the amount of original data to be encrypted, thereby improving encryption efficiency. Furthermore, extracting some data can also reduce the amount of data stored after encryption, thereby reducing the space occupied by data storage. Furthermore, by shuffling the first data that is identical to the plaintext data, the amount of data to be processed for the encrypted data can be reduced, improving encryption efficiency. Furthermore, by associating the shuffled first data with the location identifier data to generate the first encrypted data, the first data can be restored to its corresponding position in the plaintext data based on the location identifier data during subsequent decryption. This improves data decryption efficiency while ensuring data security.
[0089] In one embodiment, if Figure 6 As shown, in the above S202, "joining the location identification data with the first data after the scrambled data to obtain the first encrypted data" may include:
[0090] S2021, replacing the first data after the out-of-order processing with a preset first identifier;
[0091] S2022: Concatenate the location identification data with the first identification to obtain first encrypted data.
[0092] In this embodiment, combined with the above description, after the terminal device shuffles the first data, it can replace the shuffled first data with a preset first identifier, and concatenate the position identifier data with the first identifier to obtain first encrypted data.
[0093] Specifically, for example, when the first data is "bo", the characters (b and o) in the first data can be shuffled first, such as swapping the first and last characters or moving each character one position to the left, etc., and then the shuffled first data can be replaced with a preset first identifier. For example, the shuffled first data can be replaced with the first identifier "$@", and then the first identifier "$@" can be spliced with the position identifier data (such as "-") to obtain the first encrypted data "-$@" corresponding to the first data.
[0094] At the same time, the first data "grad" of another category is shuffled, and then the shuffled first data can be replaced with a preset first identifier. For example, the shuffled first data can be replaced with the corresponding first identifier "¥^", and then the first identifier "¥^" can be spliced with the position identifier data (such as "+") to obtain the first encrypted data "+¥^" corresponding to the first data.
[0095] It should be noted that, in this embodiment, when the terminal device encrypts the first data and the second data, it may adopt the same encryption strategy for the first data and the second data, or it may adopt different encryption strategies for the first data and the second data. Considering that the second data in the plaintext data is different data between each plaintext data, the amount of data in the second data is generally more than the amount of data in the first data, therefore, in order to improve the efficiency of data encryption, the second data with a larger amount may be algorithmically encrypted, and the first data with a smaller amount may adopt a strategy of random order and identifier replacement. There is no specific limitation on this.
[0096] Therefore, in this embodiment, the use of an identifier to replace the disordered first data further increases the encryption complexity, so that only by decrypting the first data and the second data at the same time and obtaining the data represented by the first identifier, the encryption identifier and the location identifier data can the plaintext data be restored, which increases the difficulty of data cracking and greatly improves data security.
[0097] In one embodiment, if Figure 7 As shown, in the above S201, "performing out-of-order processing on the first data" may include:
[0098] S2011, determining an exchange position for data exchange according to a target random number, wherein the exchange position includes a first position and a second position;
[0099] S2012: Exchange the data at the first position and the data at the second position in the first data.
[0100] In combination with the above embodiment, the terminal device can randomly generate a value n from the numerical interval [x, y] as a target random number before each encryption, and then generate a corresponding random order rule based on the target random number.
[0101] In this embodiment, the terminal device may determine an exchange position for data exchange according to the target random number n, wherein the exchange position in this embodiment may include at least a first position and a second position.
[0102] Furthermore, the data at the first position and the data at the second position in the first data may be exchanged to achieve out-of-order processing of the first data.
[0103] In a specific embodiment, in S2011 above, “determining the exchange position for data exchange according to the target random number” may include:
[0104] Determine a position in the first data corresponding to the target random number as a first position;
[0105] determining a second position according to a result of an operation between the first position and the target random number;
[0106] And / or, the second position is determined based on the data at the first position and the number of characters in the first data.
[0107] In this embodiment, before performing the scrambling process, the terminal device can determine the target random number, for example, by randomly selecting a value from [1, 5]. Assuming the selected value is 1, the target random number n = 1. Based on this, the terminal device can use the position in the first data corresponding to the target random number as the first position. For example, the position in the first data that is the same as the target random number can be directly used as the first position. For example, if the target random number is 1, then for the first data "grad", the position of "g" in the data can be used as the first position. The character "g" is the data to be exchanged.
[0108] The second position can then be determined based on the calculation result between the first position and the target random number.
[0109] Specifically, for example, when the result of the operation in this embodiment is a modulo operation, the first position can be subjected to a modulo operation with the target random number to obtain the result of the operation, and the second position can be determined based on the result of the operation. For example, for the first data "grad", the character position value range is "1-4" (the word contains 4 characters, representing the 1st to 4th characters), and when the target random number is 3, the result of the modulo calculation is "1201". At this time, if the result of the operation between the first position (for example, the position where "g" is located) and the target random number is 1, and the result of the operation between the position where "d" is located and the target random number is also 1, then the position where "d" is located can be used as the second position.
[0110] In another embodiment, for the first data, the terminal device may also shift characters with the same modulus result in the first data to the left in sequence to the position of the previous same modulus value, and move the leftmost character to the position of the last character with the same modulus value.
[0111] It can be understood that the above only lists possible disordering methods based on the results of the modulo operation. There may also be other operation results and other disorder processing operations, which are no longer listed one by one. The purpose of disorder in this embodiment is to increase the complexity of data encryption and increase the difficulty of data decryption.
[0112] In addition, the terminal device can also determine the second position based on the data at the first position and the amount of data to be exchanged. For example, for the first data "grad", the data at the first position (e.g., "g") is the first character. Since the number of characters in the first data is 4, the second position can be the position of the third character (i.e., 3=4-1, the position of "a").
[0113] In another embodiment, if there are multiple categories of first data, the nth character of the previous first data (i.e., the character corresponding to the first position in this embodiment) and the mnth character of the next first data (i.e., the character at the second position in this embodiment) can be interchanged, and / or the mnth character of the previous first data and the nth character of the next first data can be interchanged, where m is the number of characters in each word.
[0114] For example, if there are multiple categories of first data, such as first data "grad" and first data "bo", the second position can be a position in the first data of another category. Specifically, if the first position is the position of "g" in the first data "grad", then the second position can be the position of "b" in the first data "bo" (that is, the number of characters in the first data "bo" is 2, 1=2-1).
[0115] In a specific embodiment, the result of "-bo,+grad" after being processed by the above-mentioned disorder rule is "-rd,+baog", and then the result is subjected to the logo replacement, and the result may be "-$@,+¥^".
[0116] In another embodiment, in combination with the above description, the second data and the first data may adopt the same encryption strategy. This embodiment may also be described by the process of out-of-order processing of the second data:
[0117] The terminal device can randomly generate a target random number n from the numerical interval [x, y] each time it encrypts; for the second data, the n value is modulo operation performed in turn according to the position of the characters in the data to obtain the modulo value corresponding to each character, and then the word can be exchanged according to the modulo value of each character in the data and the n value.
[0118] Taking the second data "consumption,redom,e,ual,name,ost" as an example, the out-of-order processing process in this embodiment is described:
[0119] Before performing out-of-order processing, the terminal device can perform the following operations:
[0120] (1) Assume that a value is randomly selected from [2,5]. Assume that the selected value is 3, then the target random number n = 3;
[0121] (2) Take the modulo 3 for each character position in each word. For example, the character position value range of "consumption" is "1-11" (the word contains 11 characters, that is, it represents the 1st to the 11th characters). The result of taking the modulo of each character is "12012012012" (corresponding to each character of consumption). Similarly, the modulo of "redom" is "12012", "e" is "1", and so on.
[0122] On this basis, the disorder rules based on the value of n can include:
[0123] (1) swap the nth character and the nth-to-last character (i.e., the character at the second position in this embodiment) of each word. Assuming n=3, “consumption” is swapped to “coisumptnon” and “redom” is swapped to “redom”;
[0124] (2) Calculating the result of the operation between the first position and the target random number, wherein the result of the operation may be the remainder value corresponding to each character, and then shifting the characters with the same remainder value in each word to the left in turn to the position of the previous character with the same remainder value, and the leftmost character to the position of the last character with the same remainder value. For example, for "consumption", the result of shifting the character with the remainder value of 1 to the left is "soipumotncn", and the result of "redom" is "oedrm";
[0125] (3) For two adjacent words, first swap the nth character of the previous word with the mnth character of the next word, and then swap the mnth character of the previous word with the nth character of the next word, where m is the total number of characters in each word (for example, "soipumotncn" is swapped to "soepumotdcn").
[0126] It's understandable that in the above shuffling rules, when n is greater than m, the last character is taken as the nth character, and the first character is taken as the nth character from the end. When mn is less than or equal to 0, the first character is taken as the mnth character. The result of the above processing of "consumption,-redom,+e,+ual,name,-ost" is "soepumodncn,-oterm,+u,+aae,omtn,-isl".
[0127] On this basis, the terminal device can replace the target random number n=3 with the symbol “*” and temporarily store it for subsequent decryption.
[0128] The above only lists a variety of possible disorder rules. There may be other disorder rules, which are not listed one by one.
[0129] In a specific embodiment, if the first encrypted data is "-$@" and "+¥^", the second encrypted data is "11101000101010101010101010", and the encryption identifier is "*", the third encrypted data generated at this time can be "11101000101010101010101010*-$@, +¥^", and the encrypted data is stored.
[0130] Therefore, this embodiment uses random numbers to process the word disorder method, and uses random numbers to perform character exchange operations in the disorder processing rules. Because the random numbers are different each time, the character exchange positions during processing are also different, and then the word disorder results after processing are also different, which increases the randomness of the results after data processing, making it more difficult to crack the rule, and can make the data more secure. Compared with traditional disorder rules that are all fixed-position character exchanges, the character exchange positions after each group of words are processed are the same, and the exchange rules are easier to crack. This embodiment significantly improves the difficulty of data cracking and ensures data security.
[0131] In one embodiment, in the above S30, “encrypting the second data to obtain second encrypted data” may include:
[0132] S301, performing out-of-order processing on the second data;
[0133] S302: Encrypt the second data after being shuffled to obtain second encrypted data.
[0134] In combination with the above-mentioned embodiment, the terminal device can respond to a data processing request, and when it detects that the data processing request is an encrypted storage request, obtain the first data and the second data in the plaintext data. The terminal device can perform shuffle processing on the first data and replace the shuffled first data with a preset first identifier, and then associate the first identifier with the location identifier data to obtain the first encrypted data.
[0135] At the same time, the terminal device may also shuffle the second data and encrypt the shuffled second data to obtain second encrypted data. It is understood that in this embodiment, the shuffling rules of the first data in the first data and the second data in the second data may be the same (or different).
[0136] For example, with respect to the second data, the terminal device may encrypt the second data to obtain second encrypted data. In this embodiment, the second data may be encrypted using a preset encryption rule. The preset encryption rule may refer to an existing encryption algorithm, such as RSA. The second encrypted data generated in this embodiment may be a string, such as 11101000101010101010101010. This string of 0s and 1s is the second encrypted data. This embodiment is merely an example of one possible second encrypted data. Different encryption algorithms may correspond to different second encrypted data, and therefore each example will not be given separately.
[0137] Therefore, in this embodiment, the first data and the second data can adopt different encryption strategies, and the first data and the second data can be encrypted separately, and the identifier is used to replace the disordered first data, which further increases the encryption complexity. Only by decrypting the first data and the second data at the same time and obtaining the data represented by the first identifier, the second identifier and the location identifier data can the plaintext data be restored, which increases the difficulty of data cracking and greatly improves data security.
[0138] Accordingly, the present application also proposes a data decryption method, which may include:
[0139] Step 1: Obtain the third encrypted data, location identification data, and fourth encrypted data in the encrypted data;
[0140] Step 2: Decrypt the third encrypted data and the fourth encrypted data respectively to obtain third data corresponding to the third encrypted data and fourth data corresponding to the fourth encrypted data;
[0141] Step 3: Sort the third data and the fourth data according to the position identification data to obtain the plaintext data corresponding to the target encrypted data.
[0142] In this embodiment, if the terminal device receives a data decryption request, it can obtain the encrypted data corresponding to the request, and obtain the third encrypted data, location identification data and fourth encrypted data in the encrypted data, and then decrypt the third encrypted data and the fourth encrypted data respectively to obtain the third data corresponding to the third encrypted data and the fourth data corresponding to the fourth encrypted data, and sort the third data and the fourth data according to the location identification data to obtain the decrypted data corresponding to the target encrypted data.
[0143] It can be understood that, in this embodiment, the data decryption process and the data encryption process are inverse processes, and reference can be made to the detailed description of each embodiment of the above-mentioned data encryption method.
[0144] For example, the terminal device can extract the encrypted part of the data (i.e., the third encrypted data and the fourth encrypted data in this embodiment) from the encrypted data, and decrypt it using the decryption rules corresponding to the encryption rules (the encryption and decryption rules have been fixed and written into the system program in advance). For example, the fourth encrypted data "11101000101010101010101010" is decrypted to obtain the disordered fourth data, and the n value replaced according to the custom symbol parsing (for example, the identifier "*" is parsed to represent n=3). Then, according to the n value, the un-disordered data corresponding to the fourth data is restored in combination with the reverse operation of the disordering process. For example, the decrypted fourth data is "soepumodncn,-oterm,+u,+aae,omtn,-isl". Assume that the reverse operation of the disordering process is: (1) the order of all the decrypted words is reversed. For two adjacent words, the nth character of the previous word is first swapped with the mnth character of the next word, and then the mnth character of the previous word is swapped with the nth character of the next word, where m is the total number of characters in each word. (2) Shift the characters with the same modulus result in each word to the right in sequence to the position of the next character with the same modulus value, and move the rightmost character to the position of the first character with the same modulus value; (3) swap the nth character and the nth-to-last character position of each word, and after processing according to the above rules, obtain the initial fourth data "consumption,-redom,+e,+ual,name,-ost".
[0145] The third encrypted data is restored to the scrambled first data according to the preset identifier replacement table. For example, the third encrypted data "-$@,+¥^" is restored to the scrambled first data "-rd,+baog". The scrambled first data can then be reversed by performing the reverse operation described above to restore the original first data. For example, the result of the reverse operation according to the rules is "-bo,+grad".
[0146] Then, based on the position identification data, the plaintext data is restored. For example, according to the content correspondence of "consumption,-redom,+e,+ual,name,-ost,-bo,+grad", the "bo" after the "-" is restored to the "-" position of the former word, and the "grad" after the "+" is restored to the "+" position of the former word. Finally, the plaintext data "consumption,boredom,grade,gradual,name,boost" is restored and returned to the user.
[0147] Therefore, in an embodiment of the present application, since the plaintext data can be divided into the same first data and the different second data during the data encryption stage, the first data can be replaced with preset position identification data, and after the first data and the second data are subjected to encryption processing operations such as scrambling and identification replacement respectively to obtain the first encrypted data and the second encrypted data, the encrypted data is determined. Since the extracted data is scrambled and then the identification is replaced, once the user cannot know the specific meaning of the identification, the data cannot be decrypted, which further increases the difficulty of data cracking. That is, during decryption, it is necessary to simultaneously determine the data encryption rules and the data represented by the identification, and combine the position identification data to restore the original plaintext data, which increases the difficulty of data cracking and ensures the security of the data.
[0148] In a specific embodiment, Figure 8 As shown, the data encryption process in this embodiment may include:
[0149] (1-1) Responding to a data encryption storage request;
[0150] (1-2) Count the words with the same subset of letters in the English words to be encrypted. For example, assuming that the data to be stored is "consumption, boredom, grade, gradual, name, boost", it can be obtained that "boostboredom" has the same letter subset "bo" and "grade" and "gradual" have the same letter subset "grad";
[0151] (1-3) Extract the same letters from words with the same subset of letters, replace them with custom identifiers, and save these subset letters. For example, extract "bo" and "grad" from "boost, name, grade, boredom, gradual, consumption", and represent the corresponding letters "bo" with "-" and "grad" with "+". The original data is represented as "consumption, -redom, +e, +ual, name, -ost", and temporarily save the subset letters "-bo, +grad". The symbols before the subset letters correspond to the replacement symbols, which are used for correspondence during later data recovery.
[0152] (1-4) The remaining words after the above extraction are processed as follows. The processing rules are as follows: a value n is randomly generated from the numerical interval [x, y] each time; for each word, the modulus operation is performed on the n value according to the character position value in the word in turn to obtain the modulus value corresponding to each character; the word is subjected to a character swap operation based on the modulus value of each character in the word and the n value, and then the n value is replaced with a custom symbol and temporarily stored. After that, the disordered data is encrypted. Assuming that the encrypted result is "111010001010101010101010", n is replaced with a logo;
[0153] (1-5) The subset of letters replaced by the symbols are first processed according to the rules established above to generate different word components. Then, the letters in these subsets are replaced with custom replacement symbols to ensure that these plaintext letters are not recognized. These replacement characters correspond one-to-one with English letters. For example, "-bo, +grad" is processed by the above rules to produce "-rd, +baog". Then, the custom character replacement is performed on this result, resulting in "-$@, +¥A";
[0154] (1-6) These processed subset plaintext characters are placed after the encrypted data and stored together. For example, the final data result after splicing is "11101000101010101010101010*-S@,+¥^", and then the result is stored.
[0155] For another example, the data decryption process in this embodiment may include:
[0156] (2-1) Respond to data decryption acquisition request;
[0157] (2-2) Obtain the encrypted part of the data and decrypt it using the decryption method corresponding to the encryption method (the encryption and decryption methods are fixedly written into the system program) to obtain the decrypted preliminary data, and parse the replaced n value according to the custom symbol. Then, based on the n value, the reverse operation of the custom rule processing is combined to restore the original word that does not contain the subset letters. For example, after decryption, "111010001 010101010101010" is obtained as "soepumodncn,-oterm,+u,+aae,omtn,-isl", * is parsed into the n value, and then restored to "consumption,-redom,+e,+ual,name,-ost" according to the reverse operation of the custom rule;
[0158] (2-3) Recover the letters of the plaintext data by comparing it with the content of the customized letter replacement table. Then, perform the reverse operation of the customized rule in the previous step on the recovered data to restore the original subset letter composition. For example, first, restore the letter correspondence of "-s@+¥^" to "-rd,+baog", and then reverse the process according to the rule to "-bo,+grad";
[0159] (2-4) combining the subset letters and the decrypted word data to restore the final word, for example: according to the content correspondence of "consumption,-redom,+e,+ual,name,-ost" and "-bo,+grad", the "bo" after "-" is restored to the "-" position of the former word, and the "grad" after "+" is restored to the "+" position of the former word, and finally restored to "consumption, boredom, grade, gradual, name, boost";
[0160] (2-5) Return the final plaintext to the user.
[0161] It should be understood that, although each step in the flowcharts involved in the above-mentioned embodiments is displayed in sequence according to the instructions of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of steps or stages in other steps.
[0162] Based on the same inventive concept, embodiments of the present application further provide a data encryption device for implementing the aforementioned data encryption method, and a data decryption device for implementing the aforementioned data decryption method. The implementation solutions provided by these devices are similar to the implementation solutions described in the aforementioned methods. Therefore, the specific limitations in the embodiments of one or more data encryption devices and data decryption devices provided below can be found in the above-mentioned limitations on the data encryption method and data decryption method, and the specific limitations are not repeated here.
[0163] This embodiment also provides a data encryption device, which can be integrated into a terminal device. Figure 9 As shown, the data encryption device may include:
[0164] A first determining module 1001 is configured to determine first data and second data in plaintext data, where the first data refers to data in the plaintext data that meets a preset condition, and the second data refers to data in the plaintext data that does not meet the preset condition;
[0165] A first encryption module 1002 is configured to replace the first data with preset location identification data, and determine first encrypted data based on the location identification data and the first data;
[0166] A second encryption module 1003 is configured to encrypt the second data to obtain second encrypted data;
[0167] The second determining module 1004 is configured to combine the location identification data, the first encrypted data, and the second encrypted data to obtain third encrypted data corresponding to the plaintext data.
[0168] In some embodiments, the second determining module 1004 is further configured to:
[0169] Determine the encryption identifier according to the identifier corresponding to the target random number;
[0170] According to a preset arrangement rule, the position identification data, the first encrypted data, the second encrypted data and the encryption identifier are arranged and concatenated to obtain third encrypted data corresponding to the plaintext data.
[0171] In some embodiments, the preset condition includes a number of occurrences greater than or equal to two times, and the first determining module 1001 is further configured to:
[0172] Dividing the characters in the plaintext data according to the types of the characters in the plaintext data to obtain a plurality of character sequences, each character sequence including at least two characters of different types;
[0173] Determining identical character sequences among the multiple character sequences, and determining data composed of characters in the identical character sequences as first data; the number of the identical character sequences is at least two;
[0174] The data in the plaintext data that does not belong to the first data is determined as the second data.
[0175] In some embodiments, the first encryption module 1002 is further configured to:
[0176] performing out-of-order processing on the first data;
[0177] The position identification data is concatenated with the first data after the disorder process to obtain first encrypted data.
[0178] In some embodiments, the first encryption module 1002 is further configured to:
[0179] Replacing the first data after the disorder processing with a preset first identifier;
[0180] The location identification data is concatenated with the first identification to obtain first encrypted data.
[0181] In some embodiments, performing out-of-order processing on the first data includes:
[0182] Determining, according to the target random number, an exchange position for data exchange, wherein the exchange position includes a first position and a second position;
[0183] The data at the first position and the data at the second position in the first data are exchanged.
[0184] In some embodiments, the data encryption device in the present application further includes:
[0185] An exchange position determination module, configured to determine an exchange position for data exchange based on a target random number, wherein the exchange position includes a first position and a second position;
[0186] The exchange module is used to exchange the data at the first position and the data at the second position in the first data.
[0187] In some embodiments, the exchange position determination module is further configured to:
[0188] Determine a position in the first data corresponding to the target random number as a first position;
[0189] determining a second position according to a result of an operation between the first position and the target random number;
[0190] And / or, the second position is determined based on the data at the first position and the number of characters in the first data.
[0191] Please refer to the description of the data encryption method in the above embodiment, and the details will not be repeated here.
[0192] Based on the same inventive concept, an embodiment of the present application further provides a computer device, which may be a server or a terminal device. The computer device includes a memory and a processor. The memory stores a computer program, and the processor implements the steps of the above-mentioned data encryption method or data decryption method when executing the computer program. Various functions are thereby achieved, such as:
[0193] Determining first data and second data in the plaintext data, where the first data refers to data in the plaintext data that meets a preset condition, and the second data refers to data in the plaintext data that does not meet the preset condition;
[0194] Replacing the first data with preset location identification data, and determining first encrypted data based on the location identification data and the first data;
[0195] encrypting the second data to obtain second encrypted data;
[0196] The location identification data, the first encrypted data, and the second encrypted data are concatenated to obtain third encrypted data corresponding to the plaintext data.
[0197] It can be seen that, on the one hand, the present application improves the data encryption processing efficiency by dividing the plaintext data into first data that meets the preset conditions and second data that does not meet the preset conditions and processing them separately, without having to encrypt the data in the plaintext data one by one; on the other hand, the present application also uses location identification data and combines the first encrypted data and the second encrypted data to generate encrypted data. Since only the data represented by the cracked location identification data can be decrypted, the present application also greatly improves data security.
[0198] The specific implementation of the above operations can be found in the previous embodiments and will not be repeated here.
[0199] In one embodiment, the computer device is a terminal device, for example, its internal structure diagram can be as follows Figure 10As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface, the display unit and the input device are connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through Wi-Fi, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a data encryption method or a data decryption method is implemented. The display unit of the computer device 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 a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device casing, or an external keyboard, touchpad or mouse, etc.
[0200] Those skilled in the art will understand that Figure 10 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0201] Based on the same inventive concept, an embodiment of the present application also provides a computer-readable storage medium, which may include: a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc.
[0202] Since the computer program stored in the computer-readable storage medium can execute any data encryption method or data decryption method provided in the embodiments of the present application, the beneficial effects that can be achieved by any data encryption method or data decryption method provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0203] Based on the same inventive concept, embodiments of the present application further provide a computer program product or computer program, which includes 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 methods provided in various optional implementations of the above embodiments.
[0204] It should be noted that the object data (including but not limited to user device information, user personal information, etc.) and conversation data 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 relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions. Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods.
[0205] Any reference to the memory, database or other media used in the various embodiments provided herein may include at least one of non-volatile and volatile memory. Non-volatile memory may 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 may include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).
[0206] The databases involved in the various embodiments provided herein may include at least one of a relational database and a non-relational database. Non-relational databases may include, but are not limited to, distributed databases based on blockchains. The processors involved in the various embodiments provided herein may include, but are not limited to, general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic units, data processing logic units based on quantum computing, and the like.
[0207] In the above-described embodiments of the data encryption device, computer-readable storage medium, computer equipment, and computer program product, the descriptions of each embodiment have different focuses. For portions not described in detail in a particular embodiment, reference can be made to the relevant descriptions of other embodiments. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes and beneficial effects of the above-described data encryption device, computer-readable storage medium, computer program product, computer equipment, and their corresponding units can be referred to in the descriptions of the data encryption method and data decryption method in the above embodiments, and the details will not be repeated here.
[0208] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, 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.
[0209] The above is a detailed introduction to a data encryption method, a data encryption device, a computer device, a computer-readable storage medium, and a computer program product provided in the embodiments of the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, based on the ideas of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A data encryption method, characterized in that: The method comprises: Determining first data and second data in the plaintext data, where the first data refers to data in the plaintext data that meets a preset condition, and the second data refers to data in the plaintext data that does not meet the preset condition; Replacing the first data with preset location identification data, and determining first encrypted data based on the location identification data and the first data; encrypting the second data to obtain second encrypted data; The location identification data, the first encrypted data, and the second encrypted data are concatenated to obtain third encrypted data corresponding to the plaintext data.
2. The method according to claim 1, wherein The step of concatenating the location identification data, the first encrypted data, and the second encrypted data to obtain third encrypted data corresponding to the plaintext data includes: Determine the encryption identifier according to the identifier corresponding to the target random number; According to a preset arrangement rule, the position identification data, the first encrypted data, the second encrypted data and the encryption identifier are arranged and concatenated to obtain third encrypted data corresponding to the plaintext data.
3. The method according to claim 1, wherein The preset condition includes that the number of occurrences is greater than or equal to two, and determining the first data and the second data in the plaintext data includes: Dividing the characters in the plaintext data according to the types of the characters in the plaintext data to obtain a plurality of character sequences, each character sequence including at least two characters of different types; Determining identical character sequences among the multiple character sequences, and determining data composed of characters in the identical character sequences as first data; the number of the identical character sequences is at least two; The data in the plaintext data that does not belong to the first data is determined as the second data.
4. The method according to claim 1, wherein The determining the first encrypted data according to the location identification data and the first data includes: performing out-of-order processing on the first data; The position identification data is concatenated with the first data after the disorder process to obtain first encrypted data.
5. The method according to claim 4, wherein The step of concatenating the position identification data with the first data after the scrambled data to obtain the first encrypted data includes: Replacing the first data after the disorder processing with a preset first identifier; The location identification data is concatenated with the first identification to obtain first encrypted data.
6. The method according to claim 4, wherein The performing out-of-order processing on the first data includes: Determining, according to the target random number, an exchange position for data exchange, wherein the exchange position includes a first position and a second position; The data at the first position and the data at the second position in the first data are exchanged.
7. The method according to claim 6, wherein The step of determining the exchange position according to the target random number includes: Determine a position in the first data corresponding to the target random number as a first position; determining a second position according to a result of an operation between the first position and the target random number; And / or, the second position is determined according to the data at the first position and the number of characters in the first data.
8. A data encryption device, characterized in that: The device comprises: a first determining module, configured to determine first data and second data in the plaintext data, wherein the first data refers to data in the plaintext data that meets a preset condition, and the second data refers to data in the plaintext data that does not meet the preset condition; a first encryption module, configured to replace the first data with preset location identification data, and determine first encrypted data based on the location identification data and the first data; a second encryption module, configured to encrypt the second data to obtain second encrypted data; The second determining module is configured to combine the location identification data, the first encrypted data, and the second encrypted data to obtain third encrypted data corresponding to the plaintext data.
9. A computer device, characterized in that: The system comprises a processor and a memory, wherein the memory stores a plurality of instructions; the processor loads instructions from the memory to execute the steps of the data encryption method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the data encryption method according to any one of claims 1 to 7.