Data encryption method, device and equipment, storage medium and program product
By conditionally matching the data type of each character in the mixed data and encrypting the retained format, the problem that the existing technology cannot encrypt the mixed data is solved, and the overall encryption and format consistency of the mixed data is achieved.
Patent Information
- Application Number
- CN202411977461.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-05-16
AI Technical Summary
The prior art cannot encrypt the retained format of mixed data including multiple data types.
The data type of each target character is determined by conditional matching, and the retained format is encrypted based on this type, and finally the encrypted characters are combined to obtain the final encrypted data.
The overall encryption of mixed data is achieved while maintaining the consistency of data format before and after encryption.
Smart Images

Figure CN120017308A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data encryption, and in particular to a data encryption method, device, equipment, storage medium, and program product. Background Art
[0002] Cryptography is one of the most effective methods to ensure data security. Format-Preserving Encryption (FPE) is widely used in various scenarios that require confidentiality because the encrypted ciphertext has the same format as the plaintext.
[0003] The current format-preserving encryption scheme in the related art can only encrypt data of completely consistent data types, for example, format-preserving encryption of a single number or letter. However, when the data to be encrypted is mixed data including multiple data types, the current related art cannot implement format-preserving encryption of the mixed data. Summary of the invention
[0004] The embodiments of the present application provide a data encryption method, apparatus, device, storage medium, and program product to implement format-preserving encryption of mixed data.
[0005] In a first aspect, an embodiment of the present application provides a data encryption method, the method comprising:
[0006] Acquire target data to be encrypted; the target data includes a plurality of characters, and the plurality of characters includes at least two data types;
[0007] For each target character among the multiple characters, determine the data type of the target character through condition matching, and perform format-preserving encryption on the target character based on the data type of the target character to obtain an encrypted target character; the target character is any one of the multiple characters;
[0008] The encrypted target characters are combined together to obtain the encrypted data of the target data.
[0009] In a second aspect, an embodiment of the present application provides a data encryption device, the device comprising:
[0010] An acquisition module is used to acquire target data to be encrypted; the target data includes a plurality of characters, and the plurality of characters includes at least two data types;
[0011] an encryption module, for each target character among the multiple characters, determining the data type of the target character through condition matching, and performing format-preserving encryption on the target character based on the data type of the target character to obtain an encrypted target character; the target character is any one of the multiple characters;
[0012] The combining module combines the encrypted target characters together to obtain the encrypted data of the target data.
[0013] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, the data encryption method as described in the first aspect is implemented.
[0014] In a fourth aspect, an embodiment of the present application provides a computer storage medium, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the data encryption method described in the first aspect is implemented.
[0015] In a fifth aspect, an embodiment of the present application provides a computer program product. When instructions in the computer program product are executed by a processor of an electronic device, the electronic device executes the data encryption method as described in the first aspect.
[0016] The data encryption method, device, equipment, storage medium, and program product of the embodiment of the present application obtain the target data to be encrypted, first determine the data type of each character included in the target data by condition matching, then perform different format-preserving encryption on characters of different data types to obtain the encrypted result of each character, and combine the encrypted results corresponding to all characters together to obtain the final encrypted data of the target data. Since different format-preserving encryptions are performed on different types of characters in the target data, the overall encryption of the mixed data is achieved. At the same time, since each character is encrypted in a format-preserving manner, the encrypted format corresponding to each character is kept consistent with the format before encryption. After further combining all the encrypted results together, it is ensured that the format of the encrypted data is consistent with the format of the target data. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solution of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0018] Figure 1 It is a flowchart of a data encryption method provided by an embodiment of the present application;
[0019] Figure 2 It is a flowchart of another data encryption method provided by an embodiment of the present application;
[0020] Figure 3It is a structural schematic diagram of a data encryption device provided by an embodiment of the present application;
[0021] Figure 4 It is a structural schematic diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0022] The features and exemplary embodiments of various aspects of the present application will be described in detail below. In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain the present application, rather than to limit the present application. For those skilled in the art, the present application can be implemented without the need for some of these specific details. The following description of the embodiments is only to provide a better understanding of the present application by illustrating the examples of the present application.
[0023] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "include..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0024] As described in the background technology, the current format-preserving encryption scheme in the related art can only encrypt data of completely consistent data types, for example, format-preserving encryption of a single number or letter. However, when the data to be encrypted is mixed data including multiple data types, the current related art cannot implement format-preserving encryption of the mixed data.
[0025] In order to solve the problems of the prior art, the embodiments of the present application provide a data encryption method, device, equipment, computer storage medium and computer program product. The data encryption method provided by the embodiments of the present application is first introduced below.
[0026] Figure 1 FIG. 1 is a flow chart of a first data encryption method provided by an embodiment of the present application. Figure 1 As shown, the method comprises the following steps:
[0027] S101, obtaining target data to be encrypted; the target data includes a plurality of characters, and the plurality of characters includes at least two data types.
[0028] During specific implementation, the target data to be encrypted is the original data. In one example, the target data to be encrypted can be data in any usage scenario that needs to be encrypted, without limitation. The acquired target data can be data directly input by the user, or it can be part of the data filtered out from a data file or database, without limitation. In an embodiment of the present application, the target data includes multiple characters, and these characters include at least two data types, that is, the target data in an embodiment of the present application includes data of multiple data types. In some embodiments, the above data types include: English type, numeric type, text type or symbol type. Among them, the text type can be Chinese, Japanese, Korean and other text types other than English.
[0029] S102, for each target character among the multiple characters, determine the data type of the target character through condition matching, and encrypt the target character in a format-preserving manner based on the data type of the target character to obtain an encrypted target character; the target character is any one of the multiple characters.
[0030] In specific implementation, after the target data is obtained, the data type of each target character included in the target data is determined through condition matching, and then each target character is encrypted in a format-preserving manner according to the data type of each target character to obtain the encrypted target character corresponding to each target character. It should be noted that the above condition matching can be set as needed and is not limited to this.
[0031] In order to quickly and efficiently determine the data type of the target character, in some embodiments, the data type of the target character is determined by condition matching, specifically including:
[0032] Transcoding the target character to Unicode to obtain the target code after the target character is transcoded;
[0033] Get the Unicode transcoding range corresponding to each data type;
[0034] Determine a target transcoding range that matches the target encoding from the transcoding ranges of the Unicode corresponding to each data type;
[0035] The data type corresponding to the target transcoding range is determined as the data type of the target character.
[0036] During specific implementation, in order to improve the efficiency of identifying the data type of each character, in the embodiment of the present application, each target character of the target data will first be unicode (uniform code) transcoded to obtain the target code after each target character is transcoded. It should be noted that, through unicode transcoding, a unified and unique code can be set for each character in each language to meet the requirements of text conversion and processing across languages and platforms. Moreover, in unicode transcoding, the codes of characters of the same data type are continuously connected together. Therefore, in unicode transcoding, characters of different data types correspond to different transcoding ranges. The data types of various characters can be accurately determined through the transcoding range. For example, in unicode transcoding, the commonly used Chinese character code range is U+4E00 to U+9FFF. When the target code corresponding to a certain character belongs to the above-mentioned Chinese character code range, it can be determined that the data type of the character is a text type, and it is a Chinese type in the text type.
[0037] In some embodiments, the data type of the target character is determined by condition matching, specifically including:
[0038] Obtain a regular matching set corresponding to each other data type; the other data types are data types other than text types among the multiple data types corresponding to the target data;
[0039] Determine whether the target character matches the regular matching set corresponding to each other data type;
[0040] In response to determining that the target character does not match any of the regular matching sets corresponding to all other data types, determining the data type of the target character as a text type;
[0041] In response to determining that the target character matches a regular matching set corresponding to a target other data type in a regular matching set corresponding to each other data type, the data type of the target character is determined as the target other data type.
[0042] During specific implementation, in an embodiment of the present application, the data type of each character of the target data can be determined by regular matching. When performing regular matching, regular matching sets corresponding to various data types can be pre-set. Considering that the text type itself has a very large amount of data, for example, there are more than 80,000 different Chinese characters in Chinese. Therefore, directly creating a regular matching set of a text type requires a large amount of memory, and the calculation process when performing regular matching will also be relatively long. Therefore, in an embodiment of the present application, the method of elimination is adopted, and regular matching sets of other data types other than the text type are first created. Then, when performing regular matching, it is first determined whether the current target character matches the regular matching sets corresponding to each other data type. If it matches, the target other data types corresponding to the regular matching set that specifically matches the current target character are determined as the data type of the target character. If it is determined that the current target character does not match the regular matching sets corresponding to all other data types, the data type of the current target character is directly determined as the text type.
[0043] S103, combining the encrypted target characters together to obtain encrypted data of the target data.
[0044] In a specific implementation, after obtaining the encrypted target characters corresponding to each character of the target data, the encrypted target characters are combined together to obtain the encrypted data of the target data. It should be noted that when combining the encrypted target characters, it can be an ordered combination, that is, combining according to the order of the encrypted target characters in the target data before they are encrypted; it can also be an unordered combination, that is, no longer combining according to the order of the encrypted target characters in the target data before they are encrypted, for example, randomly combining, at this time, the order or position of the target characters in the target data before they are encrypted can be saved, so as to accurately restore the target data through the encrypted data.
[0045] In some embodiments, the target characters are encrypted in a format-preserving manner based on the data type of the target characters to obtain the encrypted target characters, specifically including:
[0046] Determining a target preset code book for the target character from a plurality of preset code books based on the data type of the target character; the target preset code book includes a plurality of comparison marks, each comparison mark corresponds to a unique comparison character, and the comparison character is a character of the same data type as the data type of the target character;
[0047] Obtaining the original comparison mark of the target character from the target preset code book, and determining the target comparison mark corresponding to the encrypted target character based on the original comparison mark;
[0048] A target control character corresponding to the target control identifier is determined from the code book, and the target control character is used as the encrypted target character.
[0049] In specific implementation, a preset code book can be set in advance for each character of a data type, and the preset code book includes multiple comparison marks, each comparison mark corresponds to a unique comparison character, and the comparison character is a character of the same data type as the target character. For example, for English-type characters, the preset code book includes 26 comparison marks, and each comparison mark corresponds to an English letter. It should be noted that the comparison mark can be set as needed, for example, the comparison mark can be an Arabic numeral, or an mark composed of an English letter and an Arabic numeral.
[0050] After determining the data type of the current target character, the target preset code book of the target character can be determined from multiple preset code books by the data type, and then the original comparison mark of the current target character is obtained from the target preset code book, and the target comparison mark corresponding to the encrypted target character is determined according to the original comparison mark. In one example, a rule for determining the target comparison mark can be pre-set, for example, a rule can be to move the position of three marks backward on the basis of the current original comparison mark, assuming that the original comparison mark of a target character is the 4th comparison mark in the target preset code book, and then the target comparison mark corresponding to the encrypted target character can be determined by the above rule as the 7th comparison mark in the target preset code book. After determining the target comparison mark corresponding to the encrypted target character, the target comparison character corresponding to the target comparison mark in the target preset code book is used as the encrypted target character. Through the method of the present application, not only the encryption of the target character is achieved, but also the data type of the encrypted target character is kept consistent with that of the original target character.
[0051] In some embodiments, determining the target preset codebook of the target character based on the data type of the target character specifically includes:
[0052] In response to determining that the data type of the target character is a text type, performing Unicode transcoding on the target character to obtain a target code after the transcoding of the target character;
[0053] A target preset code book corresponding to the target code is determined from the multiple preset code books; there are multiple target preset code books, and each bit value of the target code corresponds to one target preset code book.
[0054] In the specific implementation, when the data type of the target character is a text type, if a preset password book is directly established based on all text type characters, it will undoubtedly require a huge workload and affect the operation speed of the encryption process. In order to avoid this situation, in the embodiment of the present application, when it is determined that the data type of the target character is a text type, the target character will be first converted to a Unicode to obtain the target code after the target character is converted. After the Unicode conversion, the text type will be converted into a code composed of Arabic numerals and English characters, and the data of Arabic numerals and English letters is obviously less, so the workload of establishing the preset password book is reduced.
[0055] In order to further improve the efficiency, a target preset code book is established for each bit value of the target code after the Unicode transcoding, so that the target code after the target character transcoding can be converted into another encrypted target code, that is, for each bit of the target value of the target code, the original comparison mark of the target value is determined from the target preset code book corresponding to the target value, and the target comparison mark corresponding to the encrypted target value is determined based on the original comparison mark, and the target comparison character corresponding to the target comparison mark of the target value is determined from the target preset code book, and the target comparison character is used as the encrypted target value. An encrypted target character can be obtained again through the encrypted target code. It should be noted that, in some embodiments, when it is found that the encrypted target character is no longer a text type, the encrypted target code can be first mapped to the transcoding range of the Unicode corresponding to the text type through a preset mapping function, and then the encrypted target character is obtained through the mapped target code, so as to ensure that the encrypted target character is a text type at this time.
[0056] In some embodiments, the encrypted target characters are combined together to obtain the encrypted data of the target data, specifically including:
[0057] Obtaining first position information of each target character in the target data;
[0058] For each target character, determining the second position information of the encrypted target character in the encrypted data based on the first position information corresponding to the target character;
[0059] The encrypted target characters are combined together based on the second position information to obtain the encrypted data of the target data.
[0060] In a specific implementation, after obtaining each encrypted target character, first determine the second position information of an encrypted target character in the encrypted data according to the first position information corresponding to each target character, and then combine each encrypted target character together according to the second position information to obtain the encrypted data of the target data. It should be noted that in order to further increase the difficulty of deciphering the encrypted data, the second position information may be position information that does not correspond to the first position information. For example, in a certain target data, the target character that ranks first may not be ranked first in the second position information in the encrypted data. Of course, the second position information may also be directly made to correspond to the first position information, and there is no limitation on this.
[0061] refer to Figure 2 , is a flow chart of another data encryption method provided in an embodiment of the present application, the method comprising the following steps:
[0062] S201, identifying the category of each character of the target data by a data identifier.
[0063] S202, remember the position of each character of the target data.
[0064] S203, forwarding the target data to different encryptors.
[0065] S204, encrypting characters of respective types through a string encryptor (symbol encryptor), an English encryptor, a number encryptor, and a text encryptor.
[0066] S205, combining contents according to the position of each character.
[0067] S206, output the encrypted data.
[0068] In the specific implementation, in this embodiment, the target data is the data to be encrypted. After the target data is obtained, the category of each character of the target data is first identified by the data identifier, and then the position of each character of the target data is remembered. Then, according to the category of each character, the characters of different categories in the target data are forwarded to different encryptors, and the characters of different types are encrypted by various encryptors. Among them, the various types of encryptors include string encryptors (symbol encryptors), English encryptors, digital encryptors and text encryptors. After encryption, the encrypted characters can be combined according to the position of each character of the target data, and finally the encrypted data is generated and output.
[0069] The data encryption method of the embodiment of the present application obtains the target data to be encrypted, first determines the data type of each character included in the target data by condition matching, then performs different format-preserving encryption on characters of different data types, obtains the encrypted result of each character, and combines the encrypted results corresponding to all characters together to obtain the final encrypted data of the target data. Since different format-preserving encryptions are performed on different types of characters in the target data, the overall encryption of the mixed data is achieved. At the same time, since each character is encrypted in a format-preserving manner, the encrypted format corresponding to each character is kept consistent with the format before encryption. After further combining all the encrypted results together, it is ensured that the format of the encrypted data is consistent with the format of the target data.
[0070] Based on the same inventive concept, corresponding to any of the above-mentioned embodiment methods, the present application also provides a data encryption device.
[0071] refer to Figure 3 , the data encryption device comprises:
[0072] The acquisition module 201 acquires target data to be encrypted; the target data includes a plurality of characters, and the plurality of characters includes at least two data types;
[0073] The encryption module 202 determines the data type of each target character among the multiple characters through condition matching, and performs format-preserving encryption on the target character based on the data type of the target character to obtain the encrypted target character; the target character is any one of the multiple characters;
[0074] The combining module 203 combines the encrypted target characters together to obtain the encrypted data of the target data.
[0075] In some embodiments, the encryption module includes:
[0076] A first determining unit determines a target preset code book for the target character from a plurality of preset code books based on a data type of the target character; the target preset code book includes a plurality of comparison marks, each comparison mark corresponds to a unique comparison character, and the comparison character is a character of the same data type as the data type of the target character;
[0077] A second determining unit is configured to obtain an original comparison mark of the target character from the target preset code book, and determine a target comparison mark corresponding to the encrypted target character based on the original comparison mark;
[0078] The third determining unit determines the target control character corresponding to the target control identifier from the code book, and uses the target control character as the encrypted target character.
[0079] In some embodiments, the first determining unit is specifically configured to:
[0080] In response to determining that the data type of the target character is a text type, performing Unicode transcoding on the target character to obtain a target code after the transcoding of the target character;
[0081] A target preset code book corresponding to the target code is determined from the multiple preset code books; there are multiple target preset code books, and each bit value of the target code corresponds to one target preset code book.
[0082] In some embodiments, the encryption module is specifically configured to:
[0083] Transcoding the target character to Unicode to obtain the target code after the target character is transcoded;
[0084] Get the Unicode transcoding range corresponding to each data type;
[0085] Determine a target transcoding range that matches the target encoding from the transcoding ranges of the Unicode corresponding to each data type;
[0086] The data type corresponding to the target transcoding range is determined as the data type of the target character.
[0087] In some embodiments, the encryption module is specifically configured to:
[0088] Obtain a regular matching set corresponding to each other data type; the other data types are data types other than text types among the multiple data types corresponding to the target data;
[0089] Determine whether the target character matches the regular matching set corresponding to each other data type;
[0090] In response to determining that the target character does not match any of the regular matching sets corresponding to all other data types, determining the data type of the target character as a text type;
[0091] In response to determining that the target character matches a regular matching set corresponding to a target other data type in a regular matching set corresponding to each other data type, the data type of the target character is determined as the target other data type.
[0092] In some embodiments, the combined module is specifically configured to:
[0093] Obtaining first position information of each target character in the target data;
[0094] For each target character, determining the second position information of the encrypted target character in the encrypted data based on the first position information corresponding to the target character;
[0095] The encrypted target characters are combined together based on the second position information to obtain the encrypted data of the target data.
[0096] In some embodiments, the data types include: English type, number type, text type or symbol type.
[0097] For the convenience of description, the above device is described in terms of functions divided into various modules. Of course, when implementing the present application, the functions of each module can be implemented in the same or multiple software and / or hardware.
[0098] The data encryption device of the above embodiment is used to implement the corresponding data encryption method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be described in detail here.
[0099] Figure 4 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application is shown.
[0100] In some embodiments the electronic device may include a processor 301 and a memory 302 storing computer program instructions.
[0101] Specifically, the processor 301 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
[0102] The memory 302 may include a large capacity memory for data or instructions. By way of example and not limitation, the memory 302 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive or a combination of two or more of these. In appropriate cases, the memory 302 may include a removable or non-removable (or fixed) medium. In appropriate cases, the memory 302 may be inside or outside the integrated gateway disaster recovery device. In a specific embodiment, the memory 302 is a non-volatile solid-state memory.
[0103] In certain embodiments, memory 302 includes a read-only memory (ROM). The ROM may be a mask-programmed ROM, a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (EEPROM), an electrically alterable ROM (EAROM), or flash memory, or a combination of two or more of the above, where appropriate.
[0104] The memory may include read-only memory (ROM), random access memory (RAM), magnetic disk storage media devices, optical storage media devices, flash memory devices, electrical, optical or other physical / tangible memory storage devices. Thus, typically, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to an aspect of the present disclosure.
[0105] The processor 301 implements any one of the data encryption methods in the above embodiments by reading and executing computer program instructions stored in the memory 302 .
[0106] In one example, the electronic device may further include a communication interface 303 and a bus 310. Figure 4 As shown, the processor 301, the memory 302, and the communication interface 303 are connected via a bus 310 and communicate with each other.
[0107] The communication interface 303 is mainly used to implement communication between various modules, devices, units and / or equipment in the embodiments of the present application.
[0108] Bus 310 includes hardware, software or both, and the parts of online data flow billing equipment are coupled to each other. For example, but not limitation, bus may include accelerated graphics port (AGP) or other graphics bus, enhanced industrial standard architecture (EISA) bus, front-end bus (FSB), hypertransport (HT) interconnection, industrial standard architecture (ISA) bus, infinite bandwidth interconnection, low pin count (LPC) bus, memory bus, micro channel architecture (MCA) bus, peripheral component interconnection (PCI) bus, PCI-Express (PCI-X) bus, serial advanced technology attachment (SATA) bus, video electronics standard association local (VLB) bus or other suitable bus or two or more of these combinations. In appropriate cases, bus 310 may include one or more buses. Although the present application embodiment describes and shows a specific bus, the present application considers any suitable bus or interconnection.
[0109] The electronic device of the above embodiment is used to implement the corresponding data encryption method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be described in detail here.
[0110] In addition, in combination with the data encryption method in the above embodiment, the embodiment of the present application can provide a computer storage medium to implement. The computer storage medium stores computer program instructions; when the computer program instructions are executed by the processor, any one of the data encryption methods in the above embodiment is implemented.
[0111] The computer instructions stored in the storage medium of the above embodiments are used to enable the computer to execute the data encryption method described in any of the above embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be repeated here.
[0112] An embodiment of the present application also provides a computer program product, including a computer program, which implements any one of the data encryption methods in the above embodiments when the computer program is processed and executed.
[0113] In some embodiments, the computer program instructions may be executed by one or more processors of a computer so that the computer and / or the processor execute the data encryption method described in the above embodiments. Corresponding to the execution subject corresponding to each step in each embodiment of the data encryption method, the processor that executes the corresponding step may belong to the corresponding execution subject.
[0114] The computer program product of the above embodiment is used to enable the computer and / or the processor to execute the data encryption method described in any of the above embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be repeated here.
[0115] It should be clear that the present application is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present application is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present application.
[0116] The functional blocks shown in the above-described block diagram can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present application are programs or code segments that are used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or a communication link by a data signal carried in a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, optical fiber media, radio frequency (RF) links, etc. The code segment can be downloaded via a computer network such as the Internet, an intranet, etc.
[0117] It should also be noted that the exemplary embodiments mentioned in this application describe some methods or systems based on a series of steps or devices. However, this application is not limited to the order of the above steps, that is, the steps can be performed in the order mentioned in the embodiment, or in a different order from the embodiment, or several steps can be performed simultaneously.
[0118] Aspects of the present disclosure are described above with reference to the flowchart and / or block diagram of the method, device (system) and computer program product according to the embodiment of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device to produce a machine so that these instructions executed by the processor of the computer or other programmable data processing device enable the implementation of the function / action specified in one or more boxes of the flowchart and / or block diagram. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field programmable logic circuit. It can also be understood that each box in the block diagram and / or flowchart and the combination of boxes in the block diagram and / or flowchart can also be implemented by dedicated hardware that performs a specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions.
[0119] The above is only a specific implementation of the present application. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes of the systems, modules and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. It should be understood that the protection scope of the present application is not limited to this. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in this application, and these modifications or replacements should be included in the protection scope of this application.
Claims
1. A data encryption method, characterized in that: include: Acquire target data to be encrypted; the target data includes a plurality of characters, and the plurality of characters includes at least two data types; For each target character among the multiple characters, determine the data type of the target character through condition matching, and perform format-preserving encryption on the target character based on the data type of the target character to obtain an encrypted target character; the target character is any one of the multiple characters; The encrypted target characters are combined together to obtain the encrypted data of the target data.
2. The method according to claim 1, characterized in that Encrypting the target character in a format-preserving manner based on the data type of the target character to obtain the encrypted target character specifically includes: Determining a target preset code book for the target character from a plurality of preset code books based on the data type of the target character; the target preset code book includes a plurality of comparison marks, each comparison mark corresponds to a unique comparison character, and the comparison character is a character of the same data type as the data type of the target character; Acquire the original comparison mark of the target character from the target preset code book, and determine the target comparison mark corresponding to the encrypted target character based on the original comparison mark; A target comparison character corresponding to the target comparison identifier is determined from the target preset code book, and the target comparison character is used as the encrypted target character.
3. The method according to claim 2, characterized in that Determining a target preset code book of the target character based on the data type of the target character specifically includes: In response to determining that the data type of the target character is a text type, performing Unicode transcoding on the target character to obtain a target code after the target character is transcoded; A target preset code book corresponding to the target code is determined from the multiple preset code books; there are multiple target preset code books, and each bit value of the target code corresponds to a target preset code book.
4. The method according to claim 1, characterized in that: The data type of the target character is determined by condition matching, specifically including: Transcoding the target character to Unicode to obtain a target code after the target character is transcoded; Get the Unicode transcoding range corresponding to each data type; Determine a target transcoding range that matches the target encoding from the transcoding ranges of the Unicode corresponding to each data type; The data type corresponding to the target transcoding range is determined as the data type of the target character.
5. The method according to claim 1, characterized in that The data type of the target character is determined by condition matching, specifically including: Obtaining a regular matching set corresponding to each other data type; the other data type is a data type other than a text type among a plurality of data types corresponding to the target data; Determine whether the target character matches a regular matching set corresponding to each other data type; In response to determining that the target character does not match any of the regular matching sets corresponding to all other data types, determining the data type of the target character as a text type; In response to determining that the target character matches a regular matching set corresponding to a target other data type in a regular matching set corresponding to each other data type, the data type of the target character is determined to be the target other data type.
6. The method according to claim 1, characterized in that The encrypted target characters are combined together to obtain the encrypted data of the target data, which specifically includes: Acquire first position information of each target character in the target data; For each target character, determining second position information of the encrypted target character in the encrypted data based on the first position information corresponding to the target character; The encrypted target characters are combined together based on the second position information to obtain encrypted data of the target data.
7. The method according to any one of claims 1 to 6, characterized in that: The data types include: English type, number type, text type or symbol type.
8. A data encryption device, characterized in that: The device comprises: An acquisition module is used to acquire target data to be encrypted; the target data includes a plurality of characters, and the plurality of characters includes at least two data types; an encryption module, for each target character among the multiple characters, determining the data type of the target character through condition matching, and performing format-preserving encryption on the target character based on the data type of the target character to obtain an encrypted target character; the target character is any one of the multiple characters; The combining module combines the encrypted target characters together to obtain the encrypted data of the target data.
9. An electronic device, characterized in that: The device comprises: a processor and a memory storing computer program instructions; When the processor executes the computer program instructions, the data encryption method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed by a processor, the data encryption method according to any one of claims 1 to 7 is implemented.
11. A computer program product, characterized in that When the instructions in the computer program product are executed by a processor of an electronic device, the electronic device executes the data encryption method as described in any one of claims 1 to 7.