Data encryption method, device and storage medium
Patent Information
- Application Number
- CN202610768291.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-05-30
- Publication Date
- 2026-10-30
AI Technical Summary
[0007]针对现有技术中存在的缺陷,本申请解决的技术问题为:如何在提高加密强度的同时,提高密钥空间规模,降低执行复杂度,并降低密钥管理成本
[0027](1)以 64位为基础替换单位,单段 64 位明文加密即可实现 64! 级别的密码空间,显著提升密码系统的安全等级,具备极强的抗暴力破解能力,通过多段扩展后,异位置置换码模式可实现 (64!)N 级别的指数级密码空间扩展,满足密码系统计算安全要求的同时,破解密文的花费与时间成本远超加密信息的价值与有效时间,能够从根本上抵御暴力破解攻击。
Smart Images

Figure CN123020022A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data encryption technology, specifically a data encryption method, device, and storage medium. Background Technology
[0002] As the core foundation of information security, cryptographic systems are evaluated primarily based on computational security, which requires meeting two key conditions: first, the cost of decrypting the ciphertext must far exceed the value of the encrypted information; and second, the time required to decrypt the ciphertext must far exceed the effective lifespan of the information. The computational complexity of the encryption and decryption algorithms is the core indicator determining the security and practicality of a cryptographic system.
[0003] Currently, mainstream symmetric encryption algorithms such as the AES series and the Chinese national standard SM4 algorithm have been widely used in various encryption scenarios, but these algorithms have the following limitations:
[0004] First, the key space is limited in size; for example, the key space for AES-256 is 2^32. 256 The key space of SM4 is 2. 128 Faced with brute-force attacks that continuously increase computing power, its security boundaries are constantly being challenged;
[0005] Second, the algorithm execution steps are complex, requiring multiple rounds of alternation, byte replacement, row shifting, column mixing and other complex operations, resulting in high computational overhead and making it difficult to adapt to low-computing-power scenarios such as IoT terminals and lightweight embedded devices.
[0006] Third, key management is costly, requiring the transmission and storage of long-length fixed keys. As the number of communication nodes increases, the complexity and security risks of key distribution, storage and maintenance increase significantly. Summary of the Invention
[0007] In view of the shortcomings of the existing technology, the technical problem to be solved by this application is: how to increase the key space size, reduce the execution complexity, and reduce the key management cost while improving the encryption strength.
[0008] To achieve the above objectives, in a first aspect, embodiments of this application provide a data encryption method, the method comprising the following steps:
[0009] Given positive integers x and e, obtain the decimal integer form of x raised to the power of e;
[0010] Map each decimal digit of a large decimal integer to a binary sequence according to its parity;
[0011] Group the binary sequence into fixed number of bits, and convert each group into a decimal integer to obtain a candidate array;
[0012] After determining the length N, remove duplicate integers from the candidate array and fill in the missing integers to generate a position permutation code of length N;
[0013] After grouping the plaintext to be encrypted into length N groups, the position permutation code is used as the position index to perform a global position replacement on each group of plaintext to be encrypted, and the ciphertext is obtained.
[0014] In conjunction with the first aspect, in one embodiment, when mapping each decimal digit of a large decimal integer to a binary sequence according to parity, even numbers are replaced with 0, and odd numbers are replaced with 1.
[0015] In conjunction with the first aspect, in one embodiment, when grouping the binary sequence by a fixed number of digits, the binary sequence is grouped into groups of fixed digits starting from the first digit, and any remaining characters at the end that are less than a fixed number of digits are discarded.
[0016] In conjunction with the first aspect, in one embodiment, the length N = 2 i And i is a positive integer ≥ 4.
[0017] In conjunction with the first aspect, in one embodiment, the method for generating a position permutation code of length N includes:
[0018] Remove duplicate integers from the candidate array and determine the missing integers based on the length N;
[0019] The missing integers are padded to the end of the candidate array in ascending order;
[0020] Obtain the position permutation code of length N.
[0021] In conjunction with the first aspect, in one embodiment, after grouping the plaintext to be encrypted into groups of length N, if it is determined that the length of a group of encrypted plaintext is less than N, characters are added to the end of the group of encrypted plaintext to make the length N.
[0022] In conjunction with the first aspect, in one embodiment, when each group of plaintext to be encrypted performs a global positional substitution, each group of plaintext to be encrypted uses the same positional substitution code.
[0023] In conjunction with the first aspect, in one embodiment, when each group of plaintext to be encrypted performs a global positional substitution, each group of plaintext to be encrypted uses an independent positional substitution code.
[0024] Secondly, embodiments of this application provide a data encryption device, which includes a processor, a memory, and a data encryption program stored in the memory and executable by the processor, wherein when the data encryption program is executed by the processor, it implements the method provided in the first aspect.
[0025] Thirdly, embodiments of this application provide a computer-readable storage medium storing a data encryption program, which, when executed, implements the method provided in the first aspect.
[0026] Compared with the prior art, the advantages of this application are:
[0027] (1) Based on the 64-bit substitution unit, a single 64-bit plaintext encryption can achieve a 64! level cryptographic space, which significantly improves the security level of the cryptographic system and has a strong resistance to brute-force attacks. After multi-segment expansion, the interpositional permutation code mode can achieve (64!). N The exponential expansion of the cryptographic space at this level not only meets the computational security requirements of cryptographic systems, but also makes the cost and time of cracking the ciphertext far exceed the value and effective time of the encrypted information, thus fundamentally resisting brute-force attacks.
[0028] (2) By generating permutations and combinations of level N!, the global position replacement of plaintext is realized. The number of permutations and combinations is sufficient, and only the position permutation code needs to be generated through a large exponential integer field. Then, the plaintext position replacement is completed based on the position permutation code. The steps are simple, the computational complexity is low, and there is no need for complex multi-round transformation operations. It can be adapted to lightweight devices with low computing power.
[0029] (3) The core key consists of only two positive integers. The two parties only need to exchange these two parameters to complete the key synchronization and encryption / decryption operations. Very few parameters are transmitted, which reduces the cost of key distribution, storage and management. At the same time, it significantly reduces the risk of leakage during key transmission. Even if a small number of parameters are leaked, the effective cracking information that attackers can use is extremely limited. Attached Figure Description
[0030] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0031] Figure 1 This is a flowchart of the data encryption method in the embodiments of this application;
[0032] Figure 2 This is a schematic diagram of the hardware structure of the data encryption device involved in the embodiments of this application. Detailed Implementation
[0033] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0034] The flowchart shown in the attached diagram is for illustrative purposes only and does not necessarily include all content and operations / steps, nor does it necessarily have to be performed in the order described. For example, some operations / steps can be broken down, combined, or partially merged, so the actual execution order may change depending on the actual situation.
[0035] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0036] Firstly, referring to Figure 1 This application provides a data encryption method, the steps of which include:
[0037] S1. Given positive integers x and e, obtain the decimal integer product of x raised to the power of e; where x is the largest integer product of x and e. e For large exponential integer fields;
[0038] S2. Map each decimal digit of the large decimal integer to a binary sequence according to its parity (e.g., replace even numbers with 0 and odd numbers with 1).
[0039] S3. Group the binary sequence into fixed number of bits, and convert each group into a decimal integer to obtain the candidate array;
[0040] S4. After determining the length N (length N starts from 0 and includes 0, 1, 2, ..., N-1), remove duplicate integers from the candidate array and fill in the missing integers to generate a position permutation code of length N. At this time, the position permutation code contains all integers of length N and has no duplicate numbers, which can be used as the encoding basis.
[0041] S5. After grouping the plaintext to be encrypted into groups of length N, use the position permutation code as the position index to perform a global position replacement on each group of plaintext to be encrypted to obtain the ciphertext.
[0042] In this embodiment, permutations and combinations of level N! can be generated. When performing global position replacement of plaintext to be encrypted, there are sufficient permutations and combinations. It is only necessary to generate position permutation codes through large exponential integer field types, and then complete the plaintext position replacement based on the position permutation codes. The steps are simple, the computational complexity is low, and there is no need for complex multi-round transformation operations. It can be adapted to lightweight devices with low computing power.
[0043] In one embodiment, when grouping the binary sequence into fixed number of digits, the binary sequence is divided into groups of fixed number of digits starting from the first digit, and the remaining characters at the end that are less than a fixed number of digits are discarded.
[0044] For example, taking a fixed number of 6 digits as an example, divide the characters into groups of 6 digits and discard any remaining characters that are less than 6 digits at the end.
[0045] In one embodiment, the method for generating a position permutation code of length N after deleting duplicate integers from the candidate array and supplementing missing integers includes:
[0046] Determine the length N=2 i And i is a positive integer ≥ 4;
[0047] Remove duplicate integers from the candidate array and determine the missing integers based on the length N;
[0048] The missing integers are padded to the end of the candidate array in ascending order;
[0049] Obtain the position permutation code of length N.
[0050] When i is 6, N is 64, and the corresponding integers are 0-63.
[0051] At this point, by using the method of swapping 0 and 1 for parity, the position permutation code is generated without the need for base conversion mapping. The 0 / 1 sequence can be generated solely through the parity of decimal numbers, which fundamentally avoids the problem of missing values caused by mapping deviation and group truncation. It can cover 100% of the full range of values from 0 to 63 and generate a stable 64-bit non-repeating, completely uniformly distributed position permutation code, providing a reliable sequence basis for global position permutation and ensuring that plaintext position replacement is without omission or repetition.
[0052] In one embodiment, after grouping the plaintext to be encrypted into groups of length N, if the length of a group of encrypted plaintext is less than N, a character (such as o) is added to the end of the group of encrypted plaintext to make the length N.
[0053] In one embodiment, the method for performing a global positional replacement on each group of plaintext to be encrypted includes:
[0054] The plaintext to be encrypted can be in the same permutation code pattern where each group of plaintexts uses the same positional permutation code, or in the different permutation code pattern where each group of plaintexts to be encrypted uses an independent positional permutation code.
[0055] It should be noted that when obtaining multiple sets of plaintext to be encrypted, each set of plaintext to be encrypted is encrypted in the order they are obtained.
[0056] The following describes the practical application of the data encryption method provided in this embodiment with specific parameters. Taking x=2, e=1276, a fixed number of bits of 6, and N=64 as an example, a position permutation code is generated. Before that, a mapping table of 6-bit binary, decimal, and character numbers is constructed. This character mapping table is shown in Table 1:
[0057] 6-bit binary Decimal character 000000 0 0 000001 1 1 000010 2 2 000011 3 3 000100 4 4 000101 5 5 000110 6 6 000111 7 7 001000 8 8 001001 9 9 001010 10 A 001011 11 B 001100 12 C 001101 13 D 001110 14 E 001111 15 F 010000 16 G 010001 17 H 010010 18 I 010011 19 J 010100 20 K 010101 21 L 010110 22 M 010111 23 N 011000 24 O 011001 25 P 011010 26 Q 011011 27 R 011100 28 S 011101 29 T 011110 30 U 011111 31 V 100000 32 W 100001 33 X 100010 34 Y 100011 35 Z 100100 36 a 100101 37 b 100110 38 c 100111 39 d 101000 40 e 101001 41 f 101010 42 g 101011 43 h 101100 44 i 101101 45 j 101110 46 k 101111 47 l 110000 48 m 110001 49 n 110010 50 o 110011 51 p 110100 52 q 110101 53 r 110110 54 s 110111 55 t 111000 56 u 111001 57 v 111010 58 w 111011 59 x 111100 60 y 111101 61 z 111110 62 # 111111 63 &
[0058] Table 1
[0059] According to Table 1, the process for generating the position permutation code includes:
[0060] A. Calculate 2 1276 Expanded decimal integer: 2 1276 =(130099152433304988524065504092051069232690778090833810066488904380045100745917003725152993021654052310530270174428512597392294578104043311351748832570966509536551618867365254322164791870769794 3809119927568461226401461709643443559858370312673054782536466543610663895103567302073128531950583278103986364850230883527775392565128337304436091619753609756358717023362589340088819462896091136);
[0061] B. According to 2 1276 Calculate the large decimal integer, perform parity mapping, and obtain the binary sequence: 11001111001110010010000110001001100101001011001001101000000010010010010111110011011110111001010010110110010110000110111111001011010000111111110010110100101110111010100111010101010011101011101 0011111011000010000010011010010011110101101100110101001100001010101011101100011100111110101010101001000100100100110111111010111100111100111100111101110111001100101100000011000010011110;
[0063] C. Starting from the first bit of the binary sequence, divide it into groups of 6 bits from left to right to obtain:
[0064] (110011, 110011, 100100, 100001, 100010, 011001, 010010, 110010, 011010, 000000, 100100, 001100, 101111, 001101, 110111, 001010, 010110, 110010, 110000, 110111, 110010, 110100, 001111, 111100, 010110, 100101, 110111, 010001, 101010, 100100, 111010, 101110, 1) 00111, 110110, 000100, 000100, 110100, 100111, 101011, 011001, 101010, 011000, 010101, 000101, 110110, 110001, 110011, 111010, 101010, 110010, 001001, 000110, 111111, 010110, 011110, 001001, 101111, 100111, 011011, 010110, 000001, 100001, 001111, 0);
[0065] Remove the "0" from the last group, convert each group to a decimal integer between 0 and 63, and obtain the candidate array:
[0066]
[0067] ;
[0068] D. Remove duplicate integers from the candidate array to obtain:
[0069] ;
[0070] Then, the missing integers are filled in to generate a position permutation code of length N:
[0071]
[0072] ;
[0073] Let the position permutation code be:
[0074] F=[p,a,X,Y,P,I,o,Q,0,C,l,D,t,A,M,m,q,F,y,b,H,g,w,k,d,s,4,h,O,L,5,n ,9,6,&,U,R,c,1,2,3,7,8,B,E,G,J,K,N,S,T,V,W,Z,e,f,i,j,r,u,v,x,z,#];
[0075] Here, F[i] represents the mapping of the i-th bit of plaintext to be encrypted to the F[i]-th bit of the ciphertext. It should be noted that i here has a numerical meaning and is not the character i in Table 1 above.
[0076] At this point, the position permutation code F = [F0, F1, ..., F 63 ], where F0=p, F1=a, ..., F 63 =#.
[0077] Based on this, extract the plaintext to be encrypted from a single group:
[0078] ;
[0079] At this point, the plaintext to be encrypted is less than 64 bits, triggering the padding condition. The character 'o' is added to the end of the plaintext to be encrypted to padded it to 64 bits, and the padded plaintext is obtained.
[0080] ;
[0081] Let the plaintext to be encrypted after the supplementation be: ,in , , ..., ;
[0082] Obtain the permutation matrix based on the supplemented plaintext to be encrypted and the position permutation code:
[0083] ;
[0084] The blank spaces in lines 2 and 4 are not layout omissions or invalid placeholders, but rather space characters contained in the plain / ciphertext itself. These spaces are presented as blanks in the matrix and together with the letter characters, they form a complete plain / ciphertext sequence to restore the true text structure.
[0085] Obtain the ciphertext:
[0086] .
[0087] The permutation rules for the above permutation matrix are as follows: Secret text equal to the The plaintext to be encrypted after bit padding ,in It is a position permutation code The inverse permutation.
[0088] Therefore, it can be seen that the 0th character T of the plaintext to be encrypted is determined by the inverse permutation. It was moved to the 51st position of the ciphertext, that is... ;
[0089] The first character 'h' in the plaintext to be encrypted is determined by the inverse permutation. It was moved to the 36th position of the ciphertext, that is... ;
[0090] The second character 'e' in the plaintext to be encrypted is determined by the inverse permutation. It was replaced by the 33rd bit of the ciphertext, that is... ;
[0091] The third character (space) of the plaintext to be encrypted is determined by inverse permutation. It was moved to the 34th position of the ciphertext, that is... ;
[0092] The 34th character (space) of the plaintext to be encrypted is determined by inverse permutation. It was moved to the 63rd position of the ciphertext, that is... ;
[0093] The 62nd character 'o' in the plaintext to be encrypted is determined by the inverse permutation. It was moved to the 61st position of the ciphertext, that is... ;
[0094] The 63rd character 'o' in the plaintext to be encrypted is determined by the inverse permutation. It was moved to the 62nd bit of the ciphertext, that is... ;
[0095] All other characters were replaced one by one according to the above replacement rules, with no omissions or repetitions.
[0096] Furthermore, taking two sets of plaintext to be encrypted as an example, such as:
[0097] ;
[0098] After dividing the total length of the plaintext to be encrypted into groups, two basic blocks are obtained (i.e., two groups of plaintext to be encrypted):
[0099] First basic block:
[0100] ;
[0101] Second (completed) basic block:
[0102] ;
[0103] Obtain the permutation matrix of the first basic block:
[0104] ;
[0105] The blank spaces in lines 2 and 4 are not layout omissions or invalid placeholders, but rather space characters contained in the plain / ciphertext itself. These spaces are presented as blanks in the matrix and together with the letter characters, they form a complete plain / ciphertext sequence to restore the true text structure.
[0106] The 0th character 'T' in the first basic block is determined by inverse permutation. It was moved to the 51st position of the ciphertext, that is... ;
[0107] The first character 'h' in the first basic block is determined by inverse permutation. It was moved to the 36th position of the ciphertext, that is... ;
[0108] The second character 'e' in the first basic block is determined by inverse permutation. It was replaced by the 33rd bit of the ciphertext, that is...
[0109] The third character (space) of the first basic block is determined by inverse permutation. It was moved to the 34th position of the ciphertext, that is... ;
[0110] The 34th character (space) of the first basic block is determined by inverse permutation. It was moved to the 63rd position of the ciphertext, that is... ;
[0111] The 62nd character 'g' in the first basic block is determined by inverse permutation. It was moved to the 61st position of the ciphertext, that is... ;
[0112] The 63rd character 'o' in the first basic block is determined by inverse permutation. It was moved to the 62nd bit of the ciphertext, that is... ;
[0113] All other characters were replaced one by one according to the above replacement rules, with no omissions or repetitions.
[0114] Finally, the ciphertext corresponding to the first basic block is obtained:
[0115] ;
[0116] Following the above process for generating position permutation codes, generate the corresponding 2 1360 The corresponding position replacement code F′=[O, #, Z, g, &, x, e, X, c, 5, q, a, n, K, 6, h, d, y, 9, u, F, 8, k, T, m, W, p, z, J, R, N, t, D, s, 2, 0, L, b, Q, 1, 3, 4, 7, A, B, C, E, G, H, I, M, P, S, U, V, Y, f, i, j, l, o, r, v, w];
[0117] Obtain the permutation matrix of the second basic block based on the position permutation code F′:
[0118] ;
[0119] The blank spaces in lines 2 and 4 are not layout omissions or invalid placeholders, but rather space characters contained in the plain / ciphertext itself. These spaces are presented as blanks in the matrix and together with the letter characters, they form a complete plain / ciphertext sequence to restore the true text structure.
[0120] The 0th character (space) of the second basic block is determined by inverse permutation. It was replaced by the 24th bit of the ciphertext, that is... ;
[0121] The first character 't' in the second basic block is determined by inverse permutation. It was moved to the 62nd bit of the ciphertext, that is... ;
[0122] The 47th character 'e' in the second basic block is determined by inverse permutation. It was moved to the 16th position of the ciphertext, that is... ;
[0123] The 48th character (space) of the second basic block is determined by inverse permutation. It was replaced by the 24th bit of the ciphertext, that is... ;
[0124] The 49th character 'g' in the second basic block is determined by inverse permutation. It was replaced by the 18th bit of the ciphertext, that is... ;
[0125] All other characters were replaced one by one according to the above replacement rules, with no omissions or repetitions.
[0126] Finally, the ciphertext corresponding to the second basic block is obtained:
[0127] .
[0128] To verify the advantages of the data encryption method provided in this application, AES-192, SM4, and AES-256 algorithms are used as comparative examples. The comparison results are shown in Table 2:
[0129] algorithm Key space size The scenario corresponding to this application Advantages of this application AES-192 Single segment 64-bit ( ) Far exceeding AES-192, with stronger resistance to brute-force attacks. SM4 Single segment 64-bit The password space has been increased by approximately times AES-256 Dual-segment 128-bit ( ) Far exceeding AES-256, suitable for high-security scenarios
[0130] Table 2
[0131] As shown in Table 2, in this application, based on a 64-bit non-repeating positional permutation code, the number of different permutations of a single segment positional substitution is 64!: This is much larger than the AES-256 key space. The level of confidentiality has been significantly improved.
[0132] To further explain, when using the same position permutation code pattern in this application, the cryptographic space for N segments of 64-bit plaintext is: For example, in the case of two 128-bit segments: ;
[0133] When using the heterodox permutation code mode, each segment independently generates a 64-bit permutation code, and the cryptographic space is 64!×64!×⋯×64! (N times), achieving further exponential expansion.
[0134] Secondly, embodiments of this application provide a data encryption device, which can be a personal computer (PC), laptop computer, server, or other device with data processing capabilities.
[0135] Reference Figure 2 , Figure 2 This is a schematic diagram of the hardware structure of the data encryption device involved in the embodiments of this application. In the embodiments of this application, the data encryption device may include a processor, a memory, a communication interface, and a communication bus.
[0136] The communication bus can be of any type and is used to interconnect the processor, memory, and communication interface.
[0137] Communication interfaces include input / output (I / O) interfaces, physical interfaces, and logical interfaces used for interconnecting devices within the data encryption device, as well as interfaces used for interconnecting the data encryption device with other devices (such as other computing devices or user equipment). Physical interfaces can be Ethernet interfaces, fiber optic interfaces, ATM interfaces, etc.; user equipment can be displays, keyboards, etc.
[0138] Memory can be various types of storage media, such as random access memory (RAM), read-only memory (ROM), non-volatile RAM (NVRAM), flash memory, optical storage, hard disk, programmable ROM (PROM), erasable PROM (EPROM), electrically erasable PROM (EEPROM), etc.
[0139] The processor can be a general-purpose processor, which can call a data encryption program stored in memory and execute the data encryption method provided in the embodiments of this application. For example, the general-purpose processor can be a central processing unit (CPU). The method executed when the data encryption program is called can be referred to in the various embodiments of the data encryption method of this application, and will not be repeated here.
[0140] Those skilled in the art will understand that Figure 2 The hardware structure shown does not constitute a limitation of this application and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0141] Thirdly, embodiments of this application also provide a computer-readable storage medium.
[0142] The present application provides a computer-readable storage medium storing a data encryption program, wherein when the data encryption program is executed by a processor, it implements the steps of the data encryption method described above.
[0143] The method implemented when the data encryption program is executed can be referred to in various embodiments of the data encryption method of this application, and will not be repeated here.
[0144] It should be noted that the sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0145] The terms "comprising" and "having," and any variations thereof, in the specification, claims, and accompanying drawings of this application are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to such process, method, product, or apparatus. The terms "first," "second," and "third," etc., are used to distinguish different objects, etc., and do not indicate a sequence, nor do they limit "first," "second," and "third" to different types.
[0146] In the description of the embodiments of this application, terms such as "exemplary," "for example," or "for instance" are used to indicate examples, illustrations, or explanations. Any embodiment or design described as "exemplary," "for example," or "for instance" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or designs. Specifically, the use of terms such as "exemplary," "for example," or "for instance" is intended to present the relevant concepts in a concrete manner.
[0147] In the description of the embodiments of this application, unless otherwise stated, " / " means "or". For example, A / B can mean A or B. The "and / or" in the text is merely a description of the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist simultaneously, and B exists alone. In addition, in the description of the embodiments of this application, "multiple" means two or more.
[0148] In some processes described in the embodiments of this application, multiple operations or steps are included in a specific order. However, it should be understood that these operations or steps may not be executed in the order they appear in the embodiments of this application, or they may be executed in parallel. The sequence number of the operation is only used to distinguish different operations, and the sequence number itself does not represent any execution order. In addition, these processes may include more or fewer operations, and these operations or steps may be executed sequentially or in parallel, and these operations or steps may be combined.
[0149] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device to execute the methods described in the various embodiments of this application.
[0150] The above are merely specific embodiments of this application, but the protection scope of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the protection scope of this application. Therefore, the protection scope of this application should be determined by the scope of the claims.
Claims
1. A data encryption method, characterized in that, The method includes the following steps: Given positive integers x and e, obtain the decimal integer form of x raised to the power of e; Map each decimal digit of a large decimal integer to a binary sequence according to its parity; Group the binary sequence into fixed number of bits, and convert each group into a decimal integer to obtain a candidate array; After determining the length N, remove duplicate integers from the candidate array and fill in the missing integers to generate a position permutation code of length N; After grouping the plaintext to be encrypted into length N groups, the position permutation code is used as the position index to perform a global position replacement on each group of plaintext to be encrypted, and the ciphertext is obtained.
2. The data encryption method according to claim 1, characterized in that, When mapping each decimal digit of a large decimal integer to a binary sequence according to its parity, even numbers are replaced with 0, and odd numbers are replaced with 1.
3. The data encryption method according to claim 1, characterized in that, When grouping binary sequences into fixed-length groups, the binary sequences are grouped from the first position, with each fixed-length group being a separate group, and any remaining characters at the end that are less than a fixed-length group are discarded.
4. The data encryption method according to claim 1, characterized in that, The length N=2 i And i is a positive integer ≥ 4.
5. The data encryption method according to claim 1, characterized in that, The method for generating a position permutation code of length N includes: Remove duplicate integers from the candidate array and determine the missing integers based on the length N; The missing integers are padded to the end of the candidate array in ascending order; Obtain the position permutation code of length N.
6. The data encryption method according to claim 1, characterized in that, After grouping the plaintext to be encrypted into groups of length N, if the length of a group of encrypted plaintext is less than N, characters are added to the end of the group of encrypted plaintext to make the length N.
7. The data encryption method according to claim 1, characterized in that, When performing global position replacement on each group of plaintext to be encrypted, the same position permutation code is used for each group of plaintext to be encrypted.
8. The data encryption method according to claim 1, characterized in that, When performing global position replacement on each group of plaintext to be encrypted, each group of plaintext to be encrypted uses an independent position permutation code.
9. A data encryption device, characterized in that, The data encryption device includes a processor, a memory, and a data encryption program stored in the memory and executable by the processor, wherein when the data encryption program is executed by the processor, it implements the steps of the data encryption method as described in any one of claims 1 to 8.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a data encryption program, wherein when the data encryption program is executed, it implements the steps of the data encryption method as described in any one of claims 1 to 8.
