Data encryption method and device, equipment and storage medium

By replacing the bits to be encrypted in the sequence to be encrypted with non-repetitive encryption masks, and removing the used encryption mask after each encryption, the problem of data encryption methods in the prior art weakening the data query function is solved, and the data encryption method in the prior art is realized. The effect of retaining the data query function during the encryption process.

CN119475363APending Publication Date: 2025-02-18RICHFIT INFORMATION TECH +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311014723.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-08-11
Publication Date
2025-02-18

AI Technical Summary

Technical Problem

When existing data encryption methods mask display user data, they weaken the data query function and cannot accurately find the corresponding users.

Method used

By obtaining the sequence to be encrypted and a non-repeat encryption mask cache queue, replacing the bits to be encrypted in the sequence to be encrypted using the encryption mask, obtaining a one-to-one corresponding and non-repeat encryption sequence, and removing it after each encryption The encryption mask used.

Benefits of technology

While encrypting the data, the data query function is retained to ensure that multiple sequences to be encrypted can obtain one-to-one corresponding and non-repeat encryption sequences.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119475363A_ABST
    Figure CN119475363A_ABST
Patent Text Reader

Abstract

The invention discloses a data encryption method and device, equipment and a storage medium, and relates to the technical field of information security. The method comprises the steps that a to-be-encrypted sequence and a first cache queue are obtained, the first cache queue comprises at least one non-repeated encryption mask, and the encryption mask is used for encrypting the to-be-encrypted sequence; replacing a to-be-encrypted bit in the to-be-encrypted sequence with a first encryption mask in the first cache queue to obtain an encrypted sequence corresponding to the to-be-encrypted sequence; and removing the first encryption mask from the first cache queue. For a plurality of to-be-encrypted sequences, encrypted sequences which are in one-to-one correspondence with the to-be-encrypted sequences and are not repeated can be obtained through the method. Therefore, when the data is encrypted, the query function of the data can be reserved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of information security technology, and in particular to a data encryption method, device, equipment and storage medium. Background Art

[0002] Data security is an important aspect of information security. Directly presenting sensitive user information may result in the leakage of basic user information. Therefore, corresponding data encryption processing is required to ensure information security.

[0003] Usually, in public scenarios involving information security, the user's relevant data will be masked to prevent information leakage. For example, "12345678901" is displayed as "123*****901" and "Zhang XX" is displayed as "Zhang xx".

[0004] However, the above method weakens the query function of the data. For example, if "12345678901" is the account name of a user, after encrypting the account name to "123*****901", it will be impossible to accurately find the corresponding user. Summary of the invention

[0005] The embodiments of the present application provide a data encryption method, device, equipment and storage medium. The technical solutions provided by the embodiments of the present application are as follows:

[0006] According to one aspect of an embodiment of the present application, a method is provided, the method comprising:

[0007] Acquire a sequence to be encrypted and a first cache queue, wherein the first cache queue includes at least one non-repeating encryption mask, and the encryption mask is used to encrypt the sequence to be encrypted;

[0008] Replace the to-be-encrypted bits in the to-be-encrypted sequence with the first encryption mask in the first cache queue to obtain an encrypted sequence corresponding to the to-be-encrypted sequence;

[0009] The first encryption mask is removed from the first cache queue.

[0010] According to one aspect of an embodiment of the present application, a device is provided, the device comprising:

[0011] An acquisition module, used for acquiring a sequence to be encrypted and a first cache queue, wherein the first cache queue includes at least one non-repeating encryption mask, and the encryption mask is used for encrypting the sequence to be encrypted;

[0012] an encryption module, configured to replace the to-be-encrypted bits in the to-be-encrypted sequence with the first encryption mask in the first cache queue, to obtain an encryption sequence corresponding to the to-be-encrypted sequence;

[0013] A removing module is used to remove the first encryption mask from the first cache queue.

[0014] According to one aspect of an embodiment of the present application, a computer device is provided, the computer device comprising a processor and a memory, the memory storing a computer program, the computer program being loaded and executed by the processor to implement the above-mentioned data encryption method.

[0015] According to one aspect of an embodiment of the present application, a computer-readable storage medium is provided, in which a computer program is stored. The computer program is loaded and executed by a processor to implement the above-mentioned data encryption method.

[0016] According to one aspect of an embodiment of the present application, a computer program product is provided, which includes a computer program stored in a computer-readable storage medium, and a processor reads and executes the computer program from the computer-readable storage medium to implement the above-mentioned data encryption method.

[0017] The technical solution provided by the embodiments of the present application includes at least the following beneficial effects:

[0018] By using the encryption mask in the first cache queue to replace the to-be-encrypted bits of the sequence to be encrypted, an encryption sequence corresponding to the sequence to be encrypted is obtained. Since the encryption masks in the first cache queue are not repeated, and the used encryption masks are removed after each encryption, for multiple sequences to be encrypted, this solution can obtain encryption sequences that correspond to the multiple sequences to be encrypted one by one and are not repeated. Thus, while encrypting the data, the query function of the data can be retained. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 It is a schematic diagram of an implementation environment of a solution provided by an embodiment of the present application;

[0020] Figure 2 is a flow chart of a data encryption method provided by an embodiment of the present application;

[0021] Figure 3 is a block diagram of a data encryption scheme provided by an embodiment of the present application;

[0022] Figure 4 is a block diagram of a data decryption solution provided by an embodiment of the present application;

[0023] Figure 5 is a block diagram of a data encryption device provided by an embodiment of the present application;

[0024] Figure 6It is a structural block diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0025] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below in conjunction with the accompanying drawings.

[0026] Please refer to Figure 1 , which shows a schematic diagram of a solution implementation environment provided by an embodiment of the present application, and the solution implementation environment may include: a terminal device 10 and a server 20.

[0027] The terminal device 10 may be an electronic device such as a mobile phone, a tablet computer, a PC (Personal Computer), a vehicle-mounted terminal, a smart home appliance, a multimedia player, etc. The terminal device 10 may be installed with a client that runs a target application, and the target application may be a data encryption application, any application that displays user information (such as an application that displays the user's account and password when the user enters the account and password), or other applications that require data masking and display, which are not limited in this application.

[0028] The server 20 can be used to provide background services for the client of the target application (such as the data encryption application) in the terminal device 10. For example, the server 20 can be the background server of the above-mentioned target application (such as the data encryption application). The server 20 can be a single server, a server cluster composed of multiple servers, or a cloud computing service center.

[0029] The terminal device 10 and the server 20 may communicate via a network, such as a wireless or wired network.

[0030] In the data encryption method provided in the embodiment of the present application, the execution subject of each step may be an electronic device. For example, the electronic device may be Figure 1 The terminal device 10 in the implementation environment of the solution shown may also be Figure 1 The server 20 in the implementation environment of the solution shown. In addition, for the convenience of explanation, the terminal device is used as the execution subject of each step in the following embodiment.

[0031] Please refer to Figure 2 , which shows a flow chart of a data encryption method provided by an embodiment of the present application. The method may include at least one of the following steps 210 to 230.

[0032] Step 210: Acquire a sequence to be encrypted and a first cache queue, wherein the first cache queue includes at least one non-repeating encryption mask, and the encryption mask is used to encrypt the sequence to be encrypted.

[0033] The cache is a buffer for data exchange, which is used to temporarily store data (frequently used data) and has a faster access speed. The first cache queue is temporarily stored in the cache.

[0034] The sequence to be encrypted can be a sequence including any characters. For example, it can include numbers, letters, symbols, text, etc. For example, the sequence to be encrypted can be a number sequence such as "12345678", a text sequence such as "Zhang XX", an alphabetic sequence such as "ABCDE", or a mixed sequence including multiple characters such as "123ABC@".

[0035] In different application scenarios, the sequence to be encrypted may be the user's account name, the user's name or other character sequence containing user information, or any other sequence that needs to be encrypted, which is not limited in this application.

[0036] The encryption mask can also be a sequence of arbitrary characters.

[0037] In some embodiments, the number of bits of the encryption mask is less than or equal to the number of bits of the sequence to be encrypted.

[0038] The number of digits in a sequence refers to the number of characters contained in the sequence. For example, "12345678" is an 8-digit sequence, and "ABCDE" is a 5-digit sequence. In the embodiments of the present application, for convenience of explanation, a digit in the sequence is referred to in order from left to right. For example, for "12345678", "1" is in the first digit and "8" is in the eighth digit.

[0039] In some embodiments, the encryption mask may include the same type of characters as the sequence to be encrypted. For example, if the sequence to be encrypted is a numeric sequence, the encryption mask may also be a numeric sequence.

[0040] In some embodiments, the encryption mask may include characters of different types from the sequence to be encrypted. For example, if the sequence to be encrypted is a numeric sequence, the encryption mask may be a letter sequence.

[0041] In the embodiment of the present application, there is no limitation on the character types included in the sequence to be encrypted and the encryption mask.

[0042] Step 220: replace the bits to be encrypted in the sequence to be encrypted with the first encryption mask in the first cache queue to obtain an encrypted sequence corresponding to the sequence to be encrypted.

[0043] In some embodiments, the first encryption mask is any encryption mask in the first cache queue.

[0044] In some embodiments, the first encryption mask is any unused encryption mask in the first cache queue.

[0045] The bits to be encrypted may include one, multiple, or all bits of the sequence to be encrypted. The bits to be encrypted may be adjacent bits or non-adjacent bits in the sequence to be encrypted. The number of bits to be encrypted is less than or equal to the number of bits of the sequence to be encrypted.

[0046] In some embodiments, the number of bits of the encryption mask is equal to the number of bits to be encrypted. For example, when the sequence to be encrypted is "12345678" and the encryption mask is "ABC", if the bits to be encrypted are the 3rd, 4th, and 5th bits in the sequence to be encrypted, the resulting encryption sequence is "12ABC678"; if the bits to be encrypted are the 2nd, 4th, and 6th bits in the sequence to be encrypted, the resulting encryption sequence is "1A3B5C78".

[0047] The number of bits in the encryption mask may be the same as or different from the number of bits to be encrypted. For example, when the sequence to be encrypted is "12345678", the bits to be encrypted are the 4th and 5th bits in the sequence to be encrypted. If the encryption mask is "AB", the resulting encryption sequence is "123AB678"; if the encryption mask is "ABCDE", the resulting encryption sequence is "123ABCDE678"; if the encryption mask is "A", the resulting encryption sequence is "123A678". In addition, it should be noted that when the number of bits in the encryption mask is different from the number of bits to be encrypted, since the encryption mask and each bit in the bit to be encrypted cannot correspond, the bits to be encrypted should be adjacent bits in the sequence to be encrypted.

[0048] When the number of bits of the encryption mask is the same as the number of bits to be encrypted, the number of bits of the obtained encryption sequence is the same as the number of bits of the sequence to be encrypted.

[0049] When the number of bits of the encryption mask is different from the number of bits to be encrypted, the obtained encrypted sequence is different from the number of bits to be encrypted. At this time, the security of the sequence to be encrypted is further improved, but since the number of bits in the sequence has changed, the functionality of the encryption sequence (such as the functionality of fuzzy query) is weakened.

[0050] Step 230: remove the first encryption mask from the first cache queue.

[0051] Removing the used first encryption mask from the first cache queue can ensure that the used encryption mask will not be used when encrypting the subsequent sequence to be encrypted, thereby ensuring a one-to-one correspondence between the sequence to be encrypted and the encryption sequence.

[0052] In some embodiments, the first encryption mask may also be marked to indicate that the first encryption mask has been used.

[0053] The technical solution provided by the embodiment of the present application obtains an encrypted sequence corresponding to the sequence to be encrypted by replacing the to-be-encrypted bits of the sequence to be encrypted with the encryption mask in the first cache queue. Since the encryption masks in the first cache queue are not repeated, and the used encryption masks are removed after each encryption, for multiple sequences to be encrypted, this solution can obtain encrypted sequences that correspond to the multiple sequences to be encrypted one by one and do not repeat each other. Thus, while encrypting the data, the query function of the data can be retained.

[0054] In some embodiments, when the number of encryption masks included in the first cache queue is less than a first preset value, the number of encryption masks included in the first cache queue is supplemented to a second preset value, and the second preset value is greater than the first preset value.

[0055] In some embodiments, the first cache queue is a blocking queue. When the blocking queue is empty, the operation of obtaining elements from the queue will be blocked, and when the blocking queue is crowded (the elements are full or the number of elements is greater than a certain value), the operation of adding elements to the queue will be blocked.

[0056] In some embodiments, the second preset value may be set to the maximum number of encryption masks that the first cache queue can accommodate, and the second preset value may be set to any integer value that is smaller than the maximum number.

[0057] In some embodiments, when a certain number of encryption masks included in the first cache queue is consumed, the encryption masks of that number are added to the first cache queue.

[0058] In some embodiments, the first cache queue uses segmented cache. For example, the first cache queue is divided into two segments, and the number of encryption masks that can be included in each segment is 100. At this time, the first cache queue can be replenished with an encryption mask of one segment every time an encryption mask of one segment is consumed. In other words, the first preset value can be 101 and the second preset value can be 200. That is, when the number of encryption masks included in the first cache queue is less than 101, the number of encryption masks included in the first cache queue is replenished to 200.

[0059] In some embodiments, the number of encryption masks included in the first cache queue is always greater than 0, that is, the encryption masks included in the first cache queue need to be replenished before they are all consumed.

[0060] Since the second preset value is greater than the first preset value, the above method can be used to add at least two encryption masks to the first cache queue each time, thereby improving the replenishment efficiency and reducing the number of I / O (Input / Output) requests.

[0061] In some embodiments, when the number of encryption masks included in the first cache queue is less than the first preset value, an encryption mask is pulled from the second cache queue to supplement the number of encryption masks included in the first cache queue to the second preset value. The second cache queue includes at least one non-repeating encryption mask, and the encryption mask included in the second cache queue is different from the encryption mask included in the first cache queue.

[0062] In some embodiments, the first cache queue uses a local cache, and the second cache queue uses a distributed cache. Using a local cache means storing data in the memory space of the same process as an application (such as a data encryption application). The reading and writing of data are completed in the same process. Therefore, the access speed to the local cache is faster. The distributed cache is an independently deployed process with an independent memory space. It is usually deployed on a different device from the application process. For example, it can be deployed on a server. Therefore, it is necessary to access the distributed cache through the network.

[0063] The above method realizes dual caching of encryption mask using local cache and distributed cache through the first cache queue and the second cache queue, which can effectively deal with sudden large-volume data encryption task requests while ensuring the reading speed of the encryption mask. In addition, since the second cache queue adopts distributed cache, the second cache queue can provide encryption masks for multiple parallel data encryption processes.

[0064] In some embodiments, when the number of encryption masks included in the second cache queue is less than a third preset value, the encryption masks in the second cache queue are supplemented.

[0065] In some embodiments, the third preset value may be set to the maximum number of encryption masks that the second cache queue can accommodate.

[0066] In some embodiments, the second cache queue is a blocking queue. When the second cache queue is not full (the number of encryption masks it includes does not reach the maximum number it can accommodate), encryption masks are added to the second cache queue to keep the second cache queue full at all times.

[0067] In some embodiments, the second cache queue may also be supplemented according to the method for supplementing the first cache queue in the above embodiments, and this application does not limit this.

[0068] In some embodiments, the encryption masks are generated sequentially.

[0069] The encryption mask is generated in sequence means that the encryption mask is generated regularly according to the rules predefined by the technicians.

[0070] Exemplarily, if the encryption mask is a 3-digit sequence of numbers, the encryption mask can be generated in the order of 000, 001, 002, ..., 999; if the encryption mask is a 3-digit sequence of letters, the encryption mask can be generated in the order of AAA, AAB, ..., AAZ, ABA, ABB, ..., ZZZ.

[0071] The above sequence is only for illustrative purposes. In actual applications, technicians can arbitrarily set the order of generating the encryption mask, and this application does not limit this.

[0072] In some embodiments, before generating an encryption mask, sequential data may be constructed, the sequential data including the correspondence between the encryption mask to be generated and its generation order. Generating the encryption mask according to the sequential data may improve generation efficiency.

[0073] The encryption mask is generated in sequence, which can improve the efficiency of encryption mask generation. In addition, since the sequence to be encrypted is unpredictable, the order of encryption requests of the sequence to be encrypted is also unpredictable. The encryption mask is generated in sequence, which can also ensure that the final encryption sequence is unpredictable, thereby ensuring data security.

[0074] In some embodiments, when generating encryption masks, the corresponding generation order of each encryption mask can be recorded, so that after the generation of the encryption mask is interrupted (for example, after a device failure is restarted), the encryption mask can be quickly generated in sequence from the encryption mask that should have been generated when the interruption occurred. For example, after the 100th encryption mask is generated in sequence, the generation is interrupted, and after the generation is resumed, the encryption mask can be generated in sequence starting from the generation of the 101st encryption mask.

[0075] In some embodiments, different types of sequences to be encrypted have different bits to be encrypted.

[0076] Different types of sequences to be encrypted indicate different types of user information, and the same types of sequences to be encrypted indicate the same type of user information. For example, the ID numbers of different users can be encrypted as the same type of sequences to be encrypted, and the mobile phone numbers of different users can also be encrypted as the same type of sequences to be encrypted, while the ID numbers and mobile phone numbers belong to different types of sequences to be encrypted.

[0077] Different types of sequences to be encrypted have different bits to be encrypted, and the same type of sequences to be encrypted have the same bits to be encrypted.

[0078] For example, when encrypting a user's mobile phone number, the 4th to 7th digits of each user's mobile phone number can be fixed as the digits to be encrypted. When encrypting account names of different users for the same application, the 1st and last digits of each user's account name can be fixed as the digits to be encrypted.

[0079] Through the above method, the data encryption method provided in this application can be used to encrypt a variety of different types of data, and can meet the different encryption requirements of various types of data.

[0080] In some embodiments, after obtaining the encryption sequence corresponding to the sequence to be encrypted, their correspondence may be added to a database, and the database is used to record the correspondence between the sequence to be encrypted and the encryption sequence.

[0081] Please refer to Figure 3 , which shows a block diagram of a data encryption scheme provided by an embodiment of the present application.

[0082] In this scheme, for the input sequence to be encrypted (such as 12345678901), first query the database to see if there is a corresponding encryption sequence for the sequence to be encrypted, that is, first determine whether the sequence to be encrypted has been encrypted as plaintext and whether there is a corresponding ciphertext. If the corresponding encryption sequence can be queried, the encryption sequence is returned directly. If not, an unused encryption mask is taken from the first cache queue (such as the local cache queue), and the encryption mask is used to replace the bits to be encrypted in the sequence to be encrypted (such as the 4th to the 8th bit) to obtain an encryption sequence (such as 123AEDFX901). Finally, after the corresponding relationship between the above encryption sequence and the sequence to be encrypted is stored in the database, the encryption sequence (such as 123AEDFX901) is returned. In addition, it should be noted that the encryption mask in the first cache queue is supplemented by the second cache queue (such as a distributed blocking queue), and encryption masks generated in sequence are continuously supplemented to the second cache queue.

[0083] Please refer to Figure 4 , which shows a block diagram of a data decryption solution provided by an embodiment of the present application.

[0084] In this scheme, for an input encryption sequence (such as 123AEDFX901), first query the database to see if there is a corresponding sequence to be encrypted. In other words, first determine whether there is a corresponding plaintext for the encryption sequence as ciphertext, and encrypt it from the plaintext. If the corresponding sequence to be encrypted can be found, the sequence to be encrypted (such as 12345678901) is directly returned. If not, an error is reported.

[0085] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.

[0086] Please refer to Figure 5, which shows a block diagram of a data encryption device provided by an embodiment of the present application. The device has the function of implementing the above-mentioned data encryption method, and the function can be implemented by hardware, or by hardware executing corresponding software. The device can be an electronic device, or it can be set in an electronic device. The device 500 may include: an acquisition module 510, an encryption module 520 and a removal module 530.

[0087] The acquisition module 510 is used to acquire a sequence to be encrypted and a first cache queue, wherein the first cache queue includes at least one non-repeating encryption mask, and the encryption mask is used to encrypt the sequence to be encrypted.

[0088] The encryption module 520 is configured to replace the to-be-encrypted bits in the to-be-encrypted sequence with the first encryption mask in the first cache queue to obtain an encryption sequence corresponding to the to-be-encrypted sequence.

[0089] The removing module 530 is configured to remove the first encryption mask from the first cache queue.

[0090] In some embodiments, the device 500 further includes: a supplement module ( Figure 5 not shown).

[0091] The supplementing module is used to supplement the number of encryption masks included in the first cache queue to a second preset value when the number of encryption masks included in the first cache queue is less than a first preset value, and the second preset value is greater than the first preset value.

[0092] In some embodiments, the supplement module is used to pull encryption masks from the second cache queue to supplement the number of encryption masks included in the first cache queue to the second preset value; wherein, the second cache queue includes at least one non-repeating encryption mask, and the encryption mask included in the second cache queue is different from the encryption mask included in the first cache queue.

[0093] In some embodiments, the first cache queue adopts local cache, and the second cache queue adopts distributed cache.

[0094] In some embodiments, the supplementing module is further configured to supplement the encryption masks in the second cache queue when the number of encryption masks included in the second cache queue is less than a third preset value.

[0095] In some embodiments, the encryption masks are generated sequentially.

[0096] In some embodiments, different types of the sequences to be encrypted have different bits to be encrypted.

[0097] It should be noted that the device provided in the above embodiment, when implementing its functions, is only illustrated by the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0098] Please refer to Figure 6 , which exemplarily shows a structural block diagram of an electronic device provided by an embodiment of the present application.

[0099] Typically, the electronic device 600 includes a processor 601 and a memory 602 .

[0100] The processor 601 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 601 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field Programmable Gate Array), and PLA (Programmable Logic Array). The processor 601 may also include a main processor and a coprocessor. The main processor is a processor for processing data in an awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in a standby state. In some embodiments, the processor 601 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 601 may also include an AI processor, which is used to process computing operations related to machine learning.

[0101] The memory 602 may include one or more computer-readable storage media, which may be tangible and non-transitory. The memory 602 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 602 stores a computer program, which is loaded and executed by the processor 601 to implement the above-mentioned data encryption method.

[0102] Those skilled in the art will understand that Figure 6The structure shown in the figure does not constitute a limitation on the electronic device 600, and may include more or less components than those shown in the figure, or combine some components, or adopt a different component arrangement.

[0103] In some embodiments, a computer-readable storage medium is further provided, wherein a computer program is stored in the storage medium, and the computer program is loaded and executed by a processor to implement the above-mentioned data encryption method.

[0104] Optionally, the computer readable storage medium may include: ROM (Read-Only Memory), RAM (Random-Access Memory), SSD (Solid State Drives) or optical disks, etc. Among them, the random access memory may include ReRAM (Resistance Random Access Memory) and DRAM (Dynamic Random Access Memory).

[0105] In some embodiments, a computer program product is also provided, which includes a computer program stored in a computer-readable storage medium, and a processor reads and executes the computer program from the computer-readable storage medium to implement the above-mentioned data encryption method.

[0106] It should be understood that the "multiple" mentioned in this article refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. In addition, the step numbers described in this article only illustrate a possible execution sequence between the steps. In some other embodiments, the above steps may not be executed in the order of the numbers, such as two steps with different numbers are executed at the same time, or two steps with different numbers are executed in the opposite order to the diagram. The embodiments of the present application are not limited to this.

[0107] The above are merely exemplary embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.

Claims

1. A data encryption method, characterized in that: The method comprises: Acquire a sequence to be encrypted and a first cache queue, wherein the first cache queue includes at least one non-repeating encryption mask, and the encryption mask is used to encrypt the sequence to be encrypted; Replace the to-be-encrypted bits in the to-be-encrypted sequence with the first encryption mask in the first cache queue to obtain an encrypted sequence corresponding to the to-be-encrypted sequence; The first encryption mask is removed from the first cache queue.

2. The method according to claim 1, characterized in that The method further comprises: When the number of encryption masks included in the first cache queue is less than a first preset value, the number of encryption masks included in the first cache queue is supplemented to a second preset value, and the second preset value is greater than the first preset value.

3. The method according to claim 2, characterized in that The step of supplementing the number of encryption masks included in the first cache queue to a second preset value includes: Pull encryption masks from the second cache queue to supplement the number of encryption masks included in the first cache queue to the second preset value; wherein the second cache queue includes at least one non-repeating encryption mask, and the encryption mask included in the second cache queue is different from the encryption mask included in the first cache queue.

4. The method according to claim 3, characterized in that The first cache queue adopts local cache, and the second cache queue adopts distributed cache.

5. The method according to claim 3, characterized in that: The method further comprises: When the number of encryption masks included in the second cache queue is less than a third preset value, the encryption masks in the second cache queue are supplemented.

6. The method according to any one of claims 1 to 5, characterized in that: The encryption masks are generated sequentially.

7. The method according to any one of claims 1 to 5, characterized in that: Different types of sequences to be encrypted have different bits to be encrypted.

8. A data encryption device, characterized in that: The device comprises: An acquisition module, used for acquiring a sequence to be encrypted and a first cache queue, wherein the first cache queue includes at least one non-repeating encryption mask, and the encryption mask is used for encrypting the sequence to be encrypted; an encryption module, configured to replace the to-be-encrypted bits in the to-be-encrypted sequence with the first encryption mask in the first cache queue, to obtain an encryption sequence corresponding to the to-be-encrypted sequence; A removing module is used to remove the first encryption mask from the first cache queue.

9. An electronic device, characterized in that: The electronic device comprises a processor and a memory, wherein a computer program is stored in the memory, and the computer program is loaded and executed by the processor to implement the 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 computer program, which is loaded and executed by a processor to implement the method according to any one of claims 1 to 7.