Data transmission method, apparatus, system, storage medium, and electronic device
By segmenting data into plaintext blocks and encrypting them using a key array, combined with hash value verification, the problem of balancing data transmission security and efficiency in existing technologies is solved, achieving efficient and secure data transmission.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HUBEI CENTURY NETWORK TECHNOLOGY CO LTD
- Filing Date
- 2023-02-21
- Publication Date
- 2026-04-24
AI Technical Summary
In existing technologies, it is difficult to balance security and efficiency in data transmission methods, especially when transmitting massive amounts of data. Complex encryption algorithms consume a lot of resources and take a long time, while fixed-key encryption methods cannot guarantee the security of data transmission.
The target plaintext data is divided into several plaintext data blocks, and mapped data blocks are generated through data mapping. The data blocks are then encrypted using a key array associated with the number of plaintext data blocks. The receiving end uses a reverse conversion mechanism to recover the plaintext data blocks and verifies the data integrity by combining the hash value.
This approach improves data transmission security and efficiency without increasing computational complexity, while reducing the processing burden on both the sending and receiving ends.
Smart Images

Figure CN116208326B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to a data transmission method, apparatus, system, storage medium, and electronic device. Background Technology
[0002] With the rapid development of the internet industry, data transmission security has always been a top priority in network transmission technology.
[0003] In related technologies, either traditional encryption methods such as DES / 3DES / AES / RSA / DSA and complex algorithms such as the national cryptographic standard SM series are used for encryption calculation; or fixed key encryption is used for encryption.
[0004] These algorithms, which use complex encryption methods, ensure the security of data transmission. However, due to their high computational complexity, they consume a lot of resources and take a long time to process data, resulting in low data transmission efficiency. Using fixed-key encryption methods cannot guarantee the security of data transmission.
[0005] When massive amounts of data need to be transmitted, the data transmission methods in related technologies cannot simultaneously guarantee the security and efficiency of data transmission. Summary of the Invention
[0006] In view of this, this application provides a data transmission method, apparatus, system, storage medium, and electronic device that can safely and efficiently transmit massive amounts of data.
[0007] To solve the above-mentioned technical problems, the technical solution of this application is implemented as follows:
[0008] In one embodiment, a data transmission method is provided, the method comprising:
[0009] The target plaintext data is divided into several plaintext data blocks based on a preset processing unit length;
[0010] Each plaintext data block of the target plaintext data is converted into a corresponding mapped data block, wherein the data block length of the mapped data block is maintained at the same as the data block length of the plaintext data block;
[0011] Using the generated first key array, each of the mapped data blocks is encrypted to obtain a corresponding ciphertext data block, wherein the first key array is associated with the number of data blocks of the plaintext data blocks obtained by segmenting the target plaintext data, and the data block length of the ciphertext data block is maintained at the same as the data block length of the plaintext data block;
[0012] All the encrypted data blocks are sent to the receiving end.
[0013] Generating the first key array includes:
[0014] A second key array and a third key array are randomly generated; wherein the array length of the second key array is the preset processing unit length; and the array length of the third key array is determined according to the number of data blocks of the plaintext data segmented from the target plaintext data.
[0015] The first key array is obtained by performing logical operations on the second key array and the third key array based on the first preset logical operation.
[0016] The step of encrypting each of the mapped data blocks using the generated first key array to obtain the corresponding ciphertext data block includes:
[0017] For each of the mapped data blocks, a logical operation is performed between the mapped data block and the first key array based on a second preset logical operation to generate a ciphertext data block corresponding to the mapped data block.
[0018] The step of converting each plaintext data block of the target plaintext data into a corresponding mapped data block includes:
[0019] For each plaintext data block, it is converted into a corresponding mapped data block based on the mapping relationship between the plaintext and the ciphertext; wherein, the plaintext is an array of sequentially generated integers ranging from 0 to a preset processing unit length minus 1; the ciphertext is an array of randomly generated non-repeating values with an array length of a preset processing unit length; the mapping relationship between the plaintext and the ciphertext is such that the element values corresponding to the same index number in the array corresponding to the plaintext and the ciphertext correspond one-to-one.
[0020] The method further includes:
[0021] A hash value is generated for each plaintext data block segmented based on the target plaintext data;
[0022] The generated hash value is then sent to the receiving end; wherein the hash value is used by the receiving end to verify whether the data transmission has been tampered with during the data transmission process.
[0023] In another embodiment, a data transmission method is provided, the method comprising:
[0024] Acquire several ciphertext data blocks from the sending end, wherein each ciphertext data block corresponds to a plaintext data block obtained by the sending end from the target plaintext data based on a preset processing unit length, and the data block length of the ciphertext data block is the same as the data block length of the corresponding plaintext data block;
[0025] Using the generated first key array, each ciphertext data block is decrypted to obtain a corresponding mapped data block. The first key array is associated with the number of data blocks of the plaintext data block segmented when the sending end generates the ciphertext data block, and the data block length of the mapped data block is kept the same as the data block length of the plaintext data block.
[0026] Each of the mapped data blocks is converted into the corresponding plaintext data block, wherein the conversion mechanism from the mapped data block to the plaintext data block is the reverse mechanism of the conversion mechanism implemented by the sending end on the plaintext data block;
[0027] All the plaintext data blocks are combined in the order in which the corresponding ciphertext data blocks are acquired to obtain the target plaintext data.
[0028] Generating the first key array includes:
[0029] Obtain the second key array and the third key array sent by the sending end; the array length of the second key array is the preset processing unit length; the array length of the third key array is related to the number of plaintext data blocks divided by the sending end when generating the ciphertext data block;
[0030] The first key array is obtained by performing logical operations on the second key array and the third key array based on the first preset logical operation.
[0031] The step of decrypting each ciphertext data block using the generated first key array to obtain the corresponding mapped data block includes:
[0032] For each of the ciphertext data blocks, a logical operation is performed between the ciphertext data block and the first key array based on a third preset logical operation to obtain the mapping data block corresponding to the ciphertext data block;
[0033] The third preset logical operation is the inverse operation of the second preset logical operation.
[0034] The step of converting each of the mapped data blocks into the corresponding plaintext data blocks includes:
[0035] For each of the mapped data blocks, it is converted into a corresponding plaintext data block based on the mapping relationship between plaintext and the ciphertext; wherein, the plaintext is an array of integers with values from 0 to a preset processing unit length minus 1; the ciphertext is an array with unique values and an array length equal to the preset processing unit length; the mapping relationship between the plaintext and the ciphertext is such that the element values corresponding to the same index number in the array corresponding to the plaintext and the ciphertext correspond one-to-one.
[0036] The method further includes:
[0037] Obtain the hash value corresponding to the ciphertext data block sent by the sender;
[0038] Perform a hash calculation on the plaintext data block corresponding to the ciphertext data block to obtain the hash value corresponding to the plaintext data block;
[0039] Determine whether the hash value corresponding to the ciphertext data block is consistent with the hash value corresponding to the plaintext data block, and verify whether the data has been tampered with during data transmission.
[0040] In one embodiment, a data transmission apparatus is provided, the apparatus comprising:
[0041] The segmentation unit is configured to perform the segmentation of the target plaintext data into several plaintext data blocks based on a preset processing unit length;
[0042] The conversion unit is configured to convert each plaintext data block of the target plaintext data into a corresponding mapped data block, wherein the data block length of the mapped data block is maintained at the same as the data block length of the plaintext data block.
[0043] The encryption unit is configured to encrypt each of the mapped data blocks using a generated first key array to obtain a corresponding ciphertext data block, wherein the first key array is associated with the number of data blocks of the plaintext data blocks obtained by segmenting the target plaintext data, and the data block length of the ciphertext data block is maintained at the same as the data block length of the plaintext data block.
[0044] The sending unit is configured to send all the encrypted data blocks to the receiving end.
[0045] In another embodiment, a transmission device is provided, the device comprising:
[0046] The acquisition unit is configured to acquire a plurality of ciphertext data blocks from the sending end, wherein each ciphertext data block corresponds to a plaintext data block obtained by the sending end from the target plaintext data based on a preset processing unit length, and the data block length of the ciphertext data block is the same as the data block length of the corresponding plaintext data block.
[0047] The decryption unit is configured to use the generated first key array to decrypt each of the ciphertext data blocks to obtain a corresponding mapped data block, wherein the first key array is associated with the number of data blocks of the plaintext data blocks segmented when the sending end generates the ciphertext data blocks, and the data block length of the mapped data block is maintained at the same as the data block length of the plaintext data blocks.
[0048] The conversion unit is configured to perform the conversion of each of the mapped data blocks into the corresponding plaintext data blocks, wherein the conversion mechanism from the mapped data blocks to the plaintext data blocks is the reverse mechanism of the conversion mechanism implemented by the sending end on the plaintext data blocks;
[0049] The concatenation unit is configured to concatenate all the plaintext data blocks in the order in which the corresponding ciphertext data blocks were acquired to obtain the target plaintext data.
[0050] In another embodiment, a data transmission system is provided, the system comprising:
[0051] The sending end divides the target plaintext data into several plaintext data blocks based on a preset processing unit length; each plaintext data block is converted into a corresponding mapping data block, wherein the length of the mapping data block is maintained at the same as the length of the plaintext data block; each mapping data block is encrypted using a generated first key array to obtain a corresponding ciphertext data block, wherein the first key array is associated with the number of plaintext data blocks obtained from the division of the target plaintext data, and the length of the ciphertext data block is maintained at the same as the length of the plaintext data block; all the ciphertext data blocks are then sent to the receiving end.
[0052] The receiving end acquires several ciphertext data blocks from the sending end, wherein each ciphertext data block corresponds to a plaintext data block obtained by the sending end from the target plaintext data based on a preset processing unit length, and the data block length of the ciphertext data block is the same as the data block length of the corresponding plaintext data block; using the generated first key array, each ciphertext data block is decrypted to obtain a corresponding mapping data block; each mapping data block is converted into a corresponding plaintext data block, wherein the conversion mechanism from the mapping data block to the plaintext data block is the reverse mechanism of the conversion mechanism implemented by the sending end for the plaintext data block; all the plaintext data blocks are combined according to the acquisition order of the corresponding ciphertext data blocks to obtain the target plaintext data.
[0053] In another embodiment, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of a data transmission method.
[0054] In another embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps of a data transmission method.
[0055] As can be seen from the above technical solution, in the above embodiment, the sending end divides the target plaintext data into several plaintext data blocks based on a preset processing unit length. First, it performs data mapping on each data block to obtain a mapped data block. Then, based on a first key array associated with the number of plaintext data blocks, it encrypts the obtained mapped data blocks to obtain ciphertext data blocks, which are then transmitted to the receiving end. After receiving the ciphertext data blocks, the receiving end decrypts the ciphertext data blocks using the first key array to obtain the mapped data blocks, and then uses a reverse conversion mechanism to obtain the plaintext data blocks corresponding to the mapped data blocks. This method divides the target plaintext data into several plaintext data blocks, encrypts each data block twice, and uses a key randomly generated each time the target plaintext data is encrypted, associated with the number of plaintext data blocks divided from the target plaintext data, thus ensuring the security of data transmission. Furthermore, the encryption key used is a mapping relationship and a key array, which does not require complex calculation algorithms and can improve the efficiency of data transmission. In this scheme, the data to be transmitted is also divided into several data blocks for encryption and decryption, so that the processing burden of the sending end and the receiving end when performing data encryption and decryption with a preset processing unit length is lower than the processing burden when the data blocks are not divided. Attached Figure Description
[0056] 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.
[0057] Figure 1 This is a schematic diagram of a data transmission system according to an embodiment of this application;
[0058] Figure 2 This is a schematic diagram of a data transmission process implemented by a sending end in an embodiment of this application;
[0059] Figure 3 This is a schematic diagram of a data transmission process implemented by a receiving end in an embodiment of this application;
[0060] Figure 4 This is a schematic diagram of another data transmission process implemented by the sending end in an embodiment of this application;
[0061] Figure 5 This is a schematic diagram of another data transmission process implemented by the receiving end in an embodiment of this application;
[0062] Figure 6 This is a schematic diagram of a data transmission device structure in an embodiment of this application;
[0063] Figure 7This is a schematic diagram of another data transmission device structure in an embodiment of this application;
[0064] Figure 8 This is a schematic diagram of the physical structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0065] 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, and 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.
[0066] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe the order or sequence of objects. It should be understood that such data can be interchanged where appropriate so that embodiments of the invention described herein can be implemented, for example, in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0067] The technical solution of the present invention will be described in detail below with reference to specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.
[0068] With the rapid development of the internet industry, data transmission security has always been a top priority in network transmission technology. Especially for massive data transmissions, it is necessary to ensure not only security but also efficiency.
[0069] Based on the above requirements, this application provides a data transmission method. The sending end divides the target plaintext data into several plaintext data blocks based on a preset processing unit length. First, each data block is mapped to obtain a mapped data block. Then, the obtained mapped data blocks are encrypted using a first key array associated with the number of plaintext data blocks, resulting in ciphertext data blocks, which are then transmitted to the receiving end. Upon receiving the ciphertext data blocks, the receiving end decrypts them using the first key array to obtain the mapped data blocks, and then uses a reverse conversion mechanism to obtain the corresponding plaintext data blocks. This method divides the target plaintext data into several plaintext data blocks and encrypts each data block twice. The key used in the second encryption is randomly generated each time the target plaintext data is encrypted, and is associated with the number of plaintext data blocks divided from the target plaintext data. This means that the encryption key is different for each transmitted target plaintext data, ensuring data transmission security. Furthermore, the encryption key used is a mapping relationship and a key array, eliminating the need for complex calculation algorithms and improving data transmission efficiency. In this scheme, the data to be transmitted is also divided into several data blocks for encryption and decryption, so that the processing burden of the sending end and the receiving end when performing data encryption and decryption with a preset processing unit length is lower than the processing burden when the data blocks are not divided.
[0070] This application provides a data transmission system in its embodiments; see [link to relevant documentation]. Figure 1 , Figure 1 This is a schematic diagram of a data transmission system according to an embodiment of this application. Figure 1 Taking a receiver and a sender as an example, the receiver and sender are the two ends for transmitting the target plaintext data. This data transmission system includes a sender and a receiver.
[0071] The sending end divides the target plaintext data into several plaintext data blocks based on a preset processing unit length; each plaintext data block of the target plaintext data is converted into a corresponding mapping data block, wherein the data block length of the mapping data block is maintained at the same length as the corresponding plaintext data block; using the generated first key array, each mapping data block is encrypted to obtain the corresponding ciphertext data block, wherein the first key array is associated with the number of data blocks of the plaintext data blocks obtained from the segmentation of the target plaintext data, and the data block length of the ciphertext data block is maintained at the same length as the corresponding plaintext data block; all ciphertext data blocks are sent to the receiving end.
[0072] The receiving end acquires several ciphertext data blocks from the sending end. Each ciphertext data block corresponds to a plaintext data block obtained by the sending end from the target plaintext data based on a preset processing unit length, and the data block length of the ciphertext data block is the same as the data block length of the corresponding plaintext data block. Using the generated first key array, each ciphertext data block is decrypted to obtain the corresponding mapping data block. The first key array is associated with the number of plaintext data blocks segmented by the sending end when generating the ciphertext data block, and the data block length of the mapping data block remains the same as the data block length of the corresponding plaintext data block. Each mapping data block is converted into a corresponding plaintext data block. The conversion mechanism from the mapping data block to the plaintext data block is the reverse mechanism of the conversion mechanism implemented by the sending end for the plaintext data block. All plaintext data blocks are concatenated according to the acquisition order of the corresponding ciphertext data blocks to obtain the target plaintext data.
[0073] When the sending end divides the target plaintext data into plaintext data blocks based on the preset processing unit length, the data block length of the last plaintext data block may be the preset processing unit length or may be less than the preset processing unit length. In this embodiment of the application, when the length does not reach the preset processing unit length, it is not necessary to pad to reach the preset processing unit length.
[0074] The preset processing unit length here is the data block length that is easy for a computer to process, such as 256.
[0075] If the target plaintext data is 1000 bytes long, it will be 256 bytes long, with the last block being 232 bytes long. No padding is needed to reach 256 bytes.
[0076] In another embodiment, as the sender and receiver of data transmission, the sender and receiver need to have stored the same plaintext and codebook mapping relationship before transmitting data, as well as a second key array used by the sender to generate the first key array;
[0077] In practice, the receiving end and the sending end can agree on consistent configurations, or the sending end can complete the configuration and then synchronize it with the receiving end.
[0078] The mapping relationship between plaintext and codebook is as follows:
[0079] The plaintext is an array of sequentially generated integers ranging from 0 to a preset processing unit length minus 1; the ciphertext is an array of randomly generated, non-repeating integers with a length equal to the preset processing unit length. The mapping relationship between the plaintext and the ciphertext is as follows: the element values corresponding to the same index number in the arrays corresponding to the plaintext and the ciphertext correspond one-to-one. That is, the first value in the array corresponding to the plaintext corresponds to the first value in the array corresponding to the ciphertext, and so on, with the last value in the array corresponding to the plaintext corresponding to the last value in the array corresponding to the ciphertext.
[0080] In practical implementation, for ease of computer processing, the non-repeating values in the encrypted text can also be integers from 0 to the preset processing unit length minus 1, only the order of the values is different from that in the plaintext. Of course, they can also exist, or they can be integers that are not from 0 to the preset processing unit length minus 1 at all. This application does not impose any restrictions on this.
[0081] The sending end converts each plaintext data block of the target plaintext data into a corresponding mapped data block, specifically including:
[0082] For each plaintext data block, it is converted into a corresponding mapped data block based on the mapping relationship between the plaintext and the codebook.
[0083] Specifically, the plaintext data block is converted into a mapped data block by finding the corresponding value in the plaintext for each byte of data in the plaintext block, determining the index number of the corresponding value in the array, finding the value corresponding to the index number in the codebook, and performing mapping and replacement.
[0084] The receiving end converts each mapped data block into a corresponding plaintext data block, specifically including:
[0085] For each mapped data block, the mapping relationship between plaintext and the codebook is used to convert it into the corresponding plaintext data block.
[0086] Specifically, the process involves finding the corresponding value for each byte of data in the mapped data block in the codebook, determining the index number of that value in the array, finding the value corresponding to that index number in the plaintext, and performing mapping and replacement to convert the mapped data block into a plaintext data block.
[0087] The sending end uses the generated first key array to encrypt each mapped data block to obtain the corresponding ciphertext data block, specifically including:
[0088] For each mapped data block, a logical operation is performed between the mapped data block and the first key array based on the second preset logical operation to generate the ciphertext data block corresponding to the mapped data block.
[0089] The sending end generates a first key array, which specifically includes:
[0090] A second key array and a third key array are randomly generated; based on a first preset logical operation, the second key array and the third key array are logically operated to obtain a first key array.
[0091] The second key array here is pre-generated, that is, generated by the sending end and the receiving end before preparing to transmit the target plaintext data, and the array length is the preset processing unit length; the array length of the third key array is determined according to the number of data blocks of plaintext data blocks into which the target plaintext data is divided.
[0092] The receiving end uses the generated first key array to decrypt each ciphertext data block to obtain the corresponding mapped data block, specifically including:
[0093] For each ciphertext data block, a logical operation is performed between the ciphertext data block and the first key array based on a third preset logical operation to obtain the corresponding mapping data block. The third preset logical operation is the inverse operation of the second preset logical operation.
[0094] The receiving end generates a first key array, which specifically includes:
[0095] Obtain the second key array and the third key array sent by the sender; and perform logical operations on the second key array and the third key array based on the first preset logical operation to obtain the first key array; wherein, the array length of the second key array is the preset processing unit length, and the array length of the third key array is related to the number of plaintext data blocks divided when the sender generates the ciphertext data block.
[0096] The second key array is synchronized by the sender to the receiver before being transmitted between the sender and receiver.
[0097] After dividing the target plaintext data into several plaintext data blocks, the sending end determines the array length of the third key array based on the number of data blocks in the divided plaintext data blocks, and randomly generates the third key array.
[0098] After generating the third key array, the sending end synchronizes the third key array with the receiving end before sending the encrypted data block to the receiving end.
[0099] Specifically, the length of the third key array is determined based on the number of data blocks in the segmented plaintext data blocks. The implementation details are as follows:
[0100] The first step is to determine the number of plaintext data blocks, as follows:
[0101] Calculate the ratio of the target plaintext data block length to the preset processing unit length, and round it up;
[0102] If the value obtained by rounding up is not greater than the ratio of the preset byte length, then the number of plaintext data blocks is the preset processing unit length.
[0103] If the value obtained by rounding up is greater than the ratio of the preset byte length, then the number of plaintext data blocks is the value obtained by rounding up.
[0104] The length of the target plaintext data is denoted as Plen, and the number of plaintext data blocks into which the target plaintext data is divided is .
[0105] The second step is to determine the length of the third key array based on the number of plaintext data blocks, specifically as follows:
[0106] The length of the third key array is denoted as Rlen. When the number of plaintext data blocks into which the target plaintext data is divided is n≤256, Rlen=256; when n>256, Rlen=n.
[0107] In the embodiments of this application, the first preset logical operation and the second preset logical operation may be the same or different.
[0108] In another embodiment,
[0109] The sending end generates a hash value for each plaintext data block segmented from the target plaintext data; and sends the generated hash value to the receiving end; the hash value is used by the receiving end to verify whether the data transmission has been tampered with during the transmission process.
[0110] The receiving end obtains the hash value corresponding to the ciphertext data block sent by the sending end; it performs hash calculation on the plaintext data block corresponding to the ciphertext data block to obtain the hash value corresponding to the plaintext data block.
[0111] Determine whether the hash value corresponding to the ciphertext data block is consistent with the hash value corresponding to the plaintext data block, and verify whether the data has been tampered with during data transmission.
[0112] The data transmission process in the embodiments of this application will now be described in detail with reference to the accompanying drawings.
[0113] See Figure 2 , Figure 2 This is a schematic diagram illustrating a data transmission process implemented by a sending end in an embodiment of this application. The specific steps are as follows:
[0114] Step 201: Divide the target plaintext data into several plaintext data blocks based on the preset processing unit length.
[0115] When dividing the target plaintext data into plaintext data blocks based on a preset processing unit length, the data block length of the last plaintext data block may be the preset processing unit length or may be less than the preset processing unit length. In this embodiment, when the length does not reach the preset processing unit length, it is not necessary to pad it to reach the preset processing unit length. The length is taken as the data block length of the current plaintext data block. In subsequent mapping and related calculations with the key, the operation can be performed as long as it is.
[0116] The preset processing unit length here is the data block length that is easy for a computer to process, such as 256.
[0117] If the target plaintext data is 1000 bytes long, it will be 256 bytes long, with the last block being 232 bytes long. No padding is needed to reach 256 bytes.
[0118] When dividing the target plaintext data into plaintext data blocks, the number of data blocks in the divided plaintext data blocks is determined as follows:
[0119] Calculate the ratio of the target plaintext data block length to the preset processing unit length, and round it up;
[0120] If the value obtained by rounding up is not greater than the ratio of the preset byte length, then the number of plaintext data blocks is the preset processing unit length.
[0121] If the value obtained by rounding up is greater than the ratio of the preset byte length, then the number of plaintext data blocks is the value obtained by rounding up.
[0122] Step 202: Convert each plaintext data block of the target plaintext data into a corresponding mapped data block, wherein the data block length of the mapped data block is kept the same as the data block length of the corresponding plaintext data block.
[0123] Step 203: Using the generated first key array, encrypt each mapped data block to obtain the corresponding ciphertext data block. The first key array is associated with the number of data blocks of the plaintext data block obtained by segmenting the target plaintext data, and the length of the ciphertext data block is kept the same as the length of the corresponding plaintext data block.
[0124] Step 202 can be seen as the first encryption of the plaintext data block, and step 203 encrypts the mapped data block, which is equivalent to further encryption of the plaintext data block. These two steps achieve double encryption. In particular, the key for the second encryption is dynamically and randomly generated based on the target plaintext data sent each time, making data transmission more secure.
[0125] Step 204: Send all encrypted data blocks to the receiving end.
[0126] In this embodiment, the sending end divides the target plaintext data into several plaintext data blocks based on a preset processing unit length. First, each data block is mapped to obtain a mapped data block. Then, the obtained mapped data blocks are encrypted based on a first key array associated with the number of plaintext data blocks, resulting in ciphertext data blocks, which are then transmitted to the receiving end. This method divides the target plaintext data into several plaintext data blocks and encrypts each data block twice. The second encryption also associates the encryption with the number of plaintext data blocks, meaning the key is dynamically and randomly generated based on the target plaintext data sent each time, ensuring data transmission security. Furthermore, the encryption key used is a mapping relationship and a key array, eliminating the need for complex calculation algorithms and improving data transmission efficiency. This scheme also divides the data to be transmitted into several data blocks for encryption and decryption, reducing the processing burden on both the sending and receiving ends when performing data encryption and decryption with a preset processing unit length compared to when data is not divided into blocks.
[0127] See Figure 3 , Figure 3 This is a schematic diagram illustrating the data transmission process implemented by a receiving end in an embodiment of this application. The specific steps are as follows:
[0128] Step 301: Obtain several ciphertext data blocks from the sender, wherein each ciphertext data block corresponds to a plaintext data block obtained by the sender from the target plaintext data based on a preset processing unit length, and the data block length of the ciphertext data block is the same as the data block length of the corresponding plaintext data block.
[0129] Step 302: Using the generated first key array, decrypt each ciphertext data block to obtain the corresponding mapping data block. The first key array is associated with the number of plaintext data blocks segmented when the sending end generates the ciphertext data block, and the length of the mapping data block is kept the same as the length of the ciphertext data block.
[0130] In practice, after generating the first key array, the received ciphertext data blocks can be decrypted without having to receive all of them before decryption.
[0131] The first key array here is generated based on relevant information, and is not sent directly by the sender.
[0132] Step 303: Convert each mapped data block into a corresponding plaintext data block. The conversion mechanism from the mapped data block to the plaintext data block is the reverse mechanism of the conversion mechanism implemented by the sending end on the plaintext data block.
[0133] Step 304: Combine all plaintext data blocks in the order in which they were acquired to obtain the target plaintext data.
[0134] In this embodiment, after receiving the ciphertext data block, the receiving end uses a first key array to decrypt the ciphertext data block to obtain a mapped data block, and then uses a reverse conversion mechanism to obtain the plaintext data block corresponding to the mapped data block. The first key array is determined based on information synchronized by the sending end. This method is based on the information synchronized by the sending end, enabling rapid decryption of the sending end's ciphertext data block. Furthermore, it does not require receiving all the ciphertext blocks corresponding to the target plaintext data; it can decrypt one block at a time. This reduces the processing burden on the receiving end when performing data decryption with a preset processing unit length compared to when data blocks are not segmented.
[0135] See Figure 4 This is a schematic diagram illustrating another data transmission process implemented by the sending end in an embodiment of this application. The specific steps are as follows:
[0136] Step 401: Divide the target plaintext data into several plaintext data blocks based on the preset processing unit length.
[0137] When dividing the target plaintext data into plaintext data blocks based on a preset processing unit length, the data block length of the last plaintext data block may be the preset processing unit length or may be less than the preset processing unit length. In this embodiment, when the length does not reach the preset processing unit length, it is not necessary to pad it to reach the preset processing unit length. The length is taken as the data block length of the current plaintext data block. In subsequent mapping and related calculations with the key, the operation can be performed as long as it is.
[0138] The preset processing unit length here is the data block length that is easy for a computer to process, such as 256.
[0139] If the target plaintext data is 1000 bytes long, it will be 256 bytes long, with the last block being 232 bytes long. No padding is needed to reach 256 bytes.
[0140] When dividing the target plaintext data into plaintext data blocks, the specific determination of the number of plaintext data blocks is as follows:
[0141] Calculate the ratio of the target plaintext data block length to the preset processing unit length, and round it up;
[0142] If the value obtained by rounding up is not greater than the ratio of the preset byte length, then the number of plaintext data blocks is the preset processing unit length.
[0143] If the value obtained by rounding up is greater than the ratio of the preset byte length, then the number of plaintext data blocks is the value obtained by rounding up.
[0144] The length of each plaintext data block is equal to the preset processing unit length when the receiving end performs data decryption, in order to ensure that decryption can be performed normally.
[0145] The length of the target plaintext data is denoted as Plen, and the number of plaintext data blocks into which the target plaintext data is divided is...
[0146] Let the plaintext data P be divided into plaintext data blocks denoted as {P1, P2, P3, ..., Pn}. Each piece of data in each plaintext data block can be represented as follows:
[0147] P1={P1[0],P1[1],P1[2],...,P1
[255] }
[0148] P2={P2[0],P2[1],P2[2],...,P2
[255] }
[0149]
[0150] Pi={Pi[0],Pi[1],Pi[2],...,Pi
[255] }
[0151]
[0152] Pn={Pn[0],Pn[1],Pn[2],...,Pn
[255] }
[0153] Step 402: Convert each plaintext data block of the target plaintext data into a corresponding mapped data block based on the mapping relationship between the plaintext and the codebook; wherein the data block length of the mapped data block is kept the same as the data block length of the corresponding plaintext data block.
[0154] The mapping relationship between plaintext and codebook in this step is pre-generated and stored by the sending end.
[0155] The plaintext is an array of integers generated sequentially, ranging from 0 to a preset processing unit length minus 1; the ciphertext is an array of randomly generated integers of the preset processing unit length, with no duplicate values. The mapping relationship between the plaintext and the ciphertext is as follows: the element values corresponding to the same index number in the arrays corresponding to the plaintext and the ciphertext correspond one-to-one. That is, the first value in the array corresponding to the plaintext corresponds to the first value in the array corresponding to the ciphertext, and so on, with the last value in the array corresponding to the plaintext corresponding to the last value in the array corresponding to the ciphertext.
[0156] The preset processing unit length is a unit length easily processed by a computer. Taking a preset processing unit length of 256 as an example, an array of 256 values from 0 to 255 is generated sequentially to form the plaintext PA. A random array of length 256 with non-repeating values is generated to form the codebook T. In specific implementation, an array of length 256 is defined, and 256 non-repeating values are randomly generated and randomly filled into the defined empty array to form the codebook. Taking the non-repeating values in the ciphertext as integers from 0 to the preset processing unit length minus 1, only with a different order than the values in the plaintext, as an example, the specific plaintext and ciphertext are as follows:
[0157] Plain text PA[0x00,0x01,0x02,...,0xff]
[0158] Codebook T[0xb7,0x18,0xf3,...,0x3c]
[0159] The mapping relationship between plaintext PA and codebook T is as follows:
[0160] The elements at the same index in the plaintext and the codebook correspond one-to-one. That is, 0x00 in the plaintext at index 1 corresponds to 0xb7 in the ciphertext, and so on, and 0xff in the plaintext at index 256 corresponds to 0x3c in the codebook.
[0161] Each byte of data in the plaintext is found to have its corresponding value in the plaintext PA. Based on the index value of this value in PA, the ciphertext value with the same index value in the codebook T is matched and the mapping and replacement are performed.
[0162] The mapping process is represented as: PA[i]->T[i], where i takes values in the range 0, 1, 2, ..., 255. Plaintext is mapped one-to-one to ciphertext, represented as CT.
[0163] This article uses a plaintext data block {0x02, 0xff}, consisting of two bytes, as an example to demonstrate the entire encryption and decryption process.
[0164] Plain text PA[0x00,0x01,0x02,...,0xff]
[0165] Codebook T[0xb7,0x18,0xf3,...,0x3c]
[0166] The value "0x02" has an index number of 2 in plaintext PA, which corresponds to the value "0xf3" with index number 2 in codebook T; the value "0xff" has an index number of 255 in plaintext PA, which corresponds to the value "0x3c" with index number 255 in codebook T.
[0167] In this example, the corresponding mapped data block is CT{0xf3,0x3c}.
[0168] P->CT.
[0169] Step 403: Obtain the generated second key array and third key array, and perform logical operations on the second key array and third key array based on the first preset logical operation to obtain the first key array.
[0170] The second key array is generated before processing the target plaintext data, and its length is the preset processing unit length; it can be obtained directly.
[0171] Taking a preset processing unit length of 256 as an example, the process of generating the second key array is as follows:
[0172] Define an empty array of length 256, randomly generate 256 values, and fill the empty array to form the second key array, denoted as IV:
[0173] IV:[0xf8,0x3a,0xb2,...,0x67].
[0174] The mapping relationship between the plaintext and the codebook, as well as the second key array, are synchronized to the corresponding receiving end. During synchronization, the data can be sent to the receiving end via a secure network transmission protocol.
[0175] After dividing the target plaintext data into plaintext data blocks, the third key data can be generated. The specific generation process includes:
[0176] The third key array is a randomly generated key array, and the length of this array is determined according to the number of plaintext data blocks.
[0177] First, determine the number of plaintext data blocks, as follows:
[0178] Calculate the ratio of the target plaintext data block length to the preset processing unit length, and round it up;
[0179] If the value obtained by rounding up is not greater than the ratio of the preset byte length, then the number of plaintext data blocks is the preset processing unit length.
[0180] If the value obtained by rounding up is greater than the ratio of the preset byte length, then the number of plaintext data blocks is the value obtained by rounding up.
[0181] The length of the target plaintext data is denoted as Plen, and the number of plaintext data blocks into which the target plaintext data is divided is .
[0182] Secondly, the length of the third key array is determined based on the number of plaintext data blocks, specifically as follows:
[0183] The length of the third key array is denoted as Rlen. When the number of plaintext data blocks into which the target plaintext data is divided is n≤256, Rlen=256; when n>256, Rlen=n.
[0184] Finally, based on the first preset logical operation, the second key array and the third key array are logically operated on to obtain the first key array.
[0185] The first preset logical operation here can be XOR, NOT, or other logical operations.
[0186] In this embodiment, the first preset logical operation is taken as XOR as an example, and the specific logical operation process is given as follows:
[0187] Perform an XOR operation on the second key data and the third key array to generate the first XOR result;
[0188] After shifting the value in the third key array, perform an XOR operation with the first XOR result to obtain the second XOR result;
[0189] The shifted third key array is shifted again, and XORed with the second XOR result to obtain the third XOR result;
[0190] This process continues until the (n-1)th XOR result is obtained as the first key array;
[0191] This involves shifting the key array, such as moving each value forward by one position except for the first value, and shifting the first value to the last value.
[0192] In a practical implementation, the bits can also be shifted backward, with the last bit shifted to the first bit. This application does not impose any restrictions on this.
[0193] Taking a preset unit length of 256 as an example, the generation of the first key array is as follows:
[0194] The second key array is represented by K0. Each value in K0 is XORed with the value corresponding to the same index in the third key array R1 to generate K1.
[0195] The array R1 is transformed into a new array R2 as follows:
[0196] R2[R1[1],R1[2],R1[3],...,R1[0]]
[0197] Next, perform an XOR operation between each value in K1 and the value with the same index in R2 to generate K2.
[0198] Ki generation method:
[0199] Ri+1[Ri[1],Ri[2],Ri[3],...,Ri[0]]
[0200] The value of i ranges from 1, 2, 3, ...
[0201] Then, perform an XOR operation between each value in Ki-1 and the value with the same index in Ri to generate Ki.
[0202] Ki=Ki-1[j]⊕Ri[j]
[0203] The value of i ranges from 1, 2, 3, ...
[0204] The value of j ranges from 0, 1, 2, ..., 255.
[0205] Example of R generation method
[0206] R1[0x3d,0x81,0xa0,...,0xc6]
[0207] R2[0x81,0xa0,0x8d,...,0x3d]
[0208] R3[0xa0,0x8d,0x51,...,0x81]
[0209]
[0210] Rn[0xc6,0x3d,0x81,...,0x75]
[0211] If the length of the third key array is 256, a single XOR operation can be performed.
[0212] Taking sending 2 bytes of data as an example, Only R1 needs to participate in the calculation, meaning no bit shifting is required:
[0213] K0[0xf8,0x3a,0xb2,...,0x67]
[0214] R1[0x3d,0x81,0xa0,...,0xc6]
[0215] K1 = K0[j] ⊕ R1[j]
[0216] K1[0xc5,0xbb,0x12,...,0xa1].
[0217] Step 404: For each mapped data block, perform logical operations on the mapped data block and the first key array based on the second preset logical operation to generate the ciphertext data block corresponding to the mapped data block.
[0218] The second preset logical operation here can be the same as or different from the first preset logical operation. Below, we'll take the example of them being the same, where the second preset logical operation is an XOR operation:
[0219] The mapped data block generated in step 404 is XORed with the first key array. Specifically, the array corresponding to the mapped data block is XORed with the value at the same index in the first key array to generate a ciphertext data block, represented as C.
[0220] Ci[j]=CTi[j]⊕Ki[j]
[0221] i = 1, 2, 3, ..., n
[0222] j = 0, 1, 2, ..., 255
[0223] CT{0xf3,0x3c}
[0224] K1[0xc5,0xbb,0x12,...,0xa1]
[0225] C1[j]=CT1[j]⊕K1[j]
[0226] In this example, C{0x36,0x87}
[0227] The ciphertext CT->C is generated by encrypting the mapped ciphertext.
[0228] Step 402 can be seen as the first encryption of the plaintext data block, and step 404 encrypts the mapped data block, which is equivalent to further encryption of the plaintext data block. Through these two steps, double encryption is achieved, making data transmission more secure.
[0229] Step 405: Send all encrypted data blocks to the receiving end.
[0230] In this embodiment, the sending end divides the target plaintext data into several plaintext data blocks based on a preset processing unit length. First, it obtains the mapping data block corresponding to each plaintext data block based on the mapping relationship between the plaintext and the codebook. Then, based on a second preset logical operation, it performs logical operations on the mapping data block and the dynamically generated first key data to obtain ciphertext data blocks, which are then transmitted to the receiving end. This scheme divides the target plaintext data into several plaintext data blocks and encrypts each data block twice. The number of plaintext data blocks is also associated during the second encryption, which can ensure the security of data transmission. Furthermore, the use of mapping and logical operations for encryption does not require complex calculation algorithms, which can improve the efficiency of data transmission.
[0231] See Figure 5This is a schematic diagram illustrating another data transmission process implemented by the receiving end in an embodiment of this application. The specific steps are as follows:
[0232] Step 501: Obtain several ciphertext data blocks from the sender, wherein each ciphertext data block corresponds to a plaintext data block obtained by the sender from the target plaintext data based on a preset processing unit length, and the data block length of the ciphertext data block is the same as the data block length of the corresponding plaintext data block.
[0233] Step 502: Obtain the second key array and the third key array synchronized by the sending end, and perform logical operations on the second key array and the third key array based on the first preset logical operation to obtain the first key array.
[0234] The first preset logical operation here can be XOR, NOT, or other logical operations.
[0235] In this embodiment, the first preset logical operation is taken as XOR as an example, and the specific logical operation process is given as follows:
[0236] Perform an XOR operation on the second key data and the third key array to generate the first XOR result;
[0237] After shifting the value in the third key array, perform an XOR operation with the first XOR result to obtain the second XOR result;
[0238] The shifted third key array is shifted again, and XORed with the second XOR result to obtain the third XOR result;
[0239] This process continues until the (n-1)th XOR result is obtained as the first key array;
[0240] This involves shifting the key array, meaning that each value except the first one is shifted forward by one position, and the first value is shifted to the last value.
[0241] Taking a preset unit length of 256 as an example, the generation of the first key array is as follows:
[0242] The second key array is represented by K0. Each value in K0 is XORed with the value corresponding to the same index in the third key array R1 to generate K1.
[0243] The array R1 is transformed into a new array R2 as follows:
[0244] R2[R1[1],R1[2],R1[3],...,R1[0]]
[0245] Next, perform an XOR operation between each value in K1 and the value with the same index in R2 to generate K2.
[0246] Ki generation method:
[0247] Ri+1[Ri[1],Ri[2],Ri[3],...,Ri[0]]
[0248] The value of i ranges from 1, 2, 3, ...
[0249] Then, perform an XOR operation between each value in Ki-1 and the value with the same index in Ri to generate Ki.
[0250] Ki=Ki-1[j]⊕Ri[j]
[0251] The value of i ranges from 1, 2, 3, ...
[0252] The value of j ranges from 0, 1, 2, ..., 255.
[0253] Example of R generation method
[0254] R1[0x3d,0x81,0xa0,...,0xc6]
[0255] R2[0x81,0xa0,0x8d,...,0x3d]
[0256] R3[0xa0,0x8d,0x51,...,0x81]
[0257]
[0258] Rn[0xc6,0x3d,0x81,...,0x75]
[0259] If the length of the third key array is 256, a single XOR operation can be performed.
[0260] Taking sending 2 bytes of data as an example, Only R1 needs to participate in the calculation, meaning no bit shifting is required:
[0261] K0[0xf8,0x3a,0xb2,...,0x67]
[0262] R1[0x3d,0x81,0xa0,...,0xc6]
[0263] K1 = K0[j] ⊕ R1[j]
[0264] K1[0xc5,0xbb,0x12,...,0xa1]
[0265] Step 503: For each ciphertext data block, perform a logical operation between the ciphertext data block and the first key array based on the third preset logical operation to obtain a mapped data block, wherein the third preset logical operation is the inverse operation of the second logical operation.
[0266] If the inverse operation of a logical operation can be achieved through the same logical operation, then the third preset logical operation is the same as the second preset logical operation, such as the logical operation: XOR.
[0267] The values in each block Ci of the received ciphertext are XORed with the values at the same index in the first key array Ki. The decrypted mapped data block is represented as CT′.
[0268] CT′i[j]=Ci[j]⊕Ki[j]
[0269] i = 1, 2, 3, ..., n
[0270] j = 0, 1, 2, ..., 255
[0271] Received C{0x36,0x87}
[0272] K1[0xc5,0xbb,0x12,...,0xa1]
[0273] In this example, CT′{0xf3,0x3c}
[0274] The received ciphertext data block is decrypted to obtain the mapped data block: C->CT′.
[0275] Step 504: For each mapped data block, convert it into the corresponding plaintext data block based on the mapping relationship between plaintext and ciphertext; wherein, the conversion mechanism from mapped data block to plaintext data block is the reverse mechanism of the conversion mechanism implemented by the sending end for plaintext data block.
[0276] Obtain the mapping relationship between the plaintext and encrypted text synchronized by the sending end; the specific mapping relationship is as follows:
[0277] The plaintext is an array of integers ranging from 0 to a preset processing unit length minus 1; the ciphertext is an array of length equal to the preset processing unit length, with no duplicate values. The mapping relationship between the plaintext and the ciphertext is as follows: the element values corresponding to the same index number in the arrays corresponding to the plaintext and the ciphertext correspond one-to-one. That is, the first value in the array corresponding to the plaintext corresponds to the first value in the array corresponding to the ciphertext, and so on, with the last value in the array corresponding to the plaintext corresponding to the last value in the array corresponding to the ciphertext.
[0278] The preset processing unit length is a unit length easily processed by a computer. Taking a preset processing unit length of 256 as an example, the plaintext is an array of 256 values from 0 to 255 in sequence; the codebook T is an array of length 256 with no repeated values. Taking the non-repeating values in the ciphertext as integers from 0 to the preset processing unit length minus 1, only the order of the values in the ciphertext is different from that in the plaintext, as an example:
[0279] Plain text PA[0x00,0x01,0x02,...,0xff]
[0280] Codebook T[0xb7,0x18,0xf3,...,0x3c]
[0281] The mapping relationship between plaintext PA and codebook T is as follows:
[0282] The elements at the same index in the plaintext and the codebook correspond one-to-one. That is, 0x00 in the plaintext at index 1 corresponds to 0xb7 in the ciphertext, and so on, and 0xff in the plaintext at index 256 corresponds to 0x3c in the codebook.
[0283] The value "0xf3" in the mapped data block has an index of 2 in the codebook PA, which corresponds to the value "0x02" with index 2 in the plaintext T; the data value "0x3c" has an index of 255 in the codebook PA, which corresponds to the value "0xff" with index 255 in the plaintext T.
[0284] The reverse mapping and restoration process is represented as: T[i]->PA[i]; where i takes values in the range 0, 1, 2, ..., 255. The ciphertext is mapped and restored to plaintext one by one, represented as P′.
[0285] In this example, P′{0x02,0xff}
[0286] Restore the plaintext CT′->P′ from the mapped data block.
[0287] Step 505: Combine all plaintext data blocks in the order in which they were acquired to obtain the target plaintext data.
[0288] In this embodiment, after receiving the ciphertext data block, the receiving end decrypts the ciphertext data block using a dynamically generated first key array based on logical operations to obtain a mapped data block, and then uses a reverse conversion mechanism to obtain the plaintext data block corresponding to the mapped data block. This scheme also divides the data to be transmitted into several data blocks for encryption and decryption, reducing the processing burden on the sending and receiving ends when performing data encryption and decryption with a preset processing unit length compared to when data blocks are not divided. Furthermore, decryption based on a dynamic first key array ensures the security of data transmission. The decryption method, using data mapping and logical operations, is more efficient than related decryption methods, requiring less complex calculations.
[0289] In this embodiment of the application, the transmitted data can also be verified using hash values, as detailed below:
[0290] The sending end generates a hash value for each plaintext data block segmented from the target plaintext data; and sends the generated hash value to the receiving end; the hash value is used by the receiving end to verify whether the data transmission has been tampered with during the transmission process.
[0291] The receiving end obtains the hash value corresponding to the ciphertext data block sent by the sending end; it performs hash calculation on the plaintext data block corresponding to the ciphertext data block to obtain the hash value corresponding to the plaintext data block.
[0292] Determine whether the hash value corresponding to the ciphertext data block is consistent with the hash value corresponding to the plaintext data block, and verify whether the data has been tampered with during data transmission.
[0293] In the embodiments of this application, the generation of the first key array used by the sending end and the receiving end is performed once for a target plaintext data, and does not need to be performed once for each data block.
[0294] Compared to resource-intensive data processing methods such as multiplication, division, exponentiation, modular arithmetic, and logarithms, the use of logical operations in this embodiment can improve data processing efficiency. During encryption and decryption, encryption is performed by dynamically generating a first key array. Since the first key array is not transmitted, the security of data transmission can be ensured.
[0295] All of the above-mentioned optional technical solutions can be combined in any way to form optional embodiments of this disclosure, and will not be described in detail here.
[0296] Based on the same inventive concept, this application also provides a data transmission device. See also Figure 6 , Figure 6 This is a schematic diagram of a data transmission device according to an embodiment of this application. The data transmission device includes:
[0297] The segmentation unit 601 is configured to perform the segmentation of the target plaintext data into several plaintext data blocks based on a preset processing unit length;
[0298] The conversion unit 602 is configured to convert each plaintext data block of the target plaintext data into a corresponding mapped data block, wherein the data block length of the mapped data block is maintained at the same as the data block length of the plaintext data block.
[0299] The encryption unit 603 is configured to use the generated first key array to encrypt each of the mapped data blocks to obtain a corresponding ciphertext data block, wherein the first key array is associated with the number of data blocks of the plaintext data blocks obtained by segmenting the target plaintext data, and the data block length of the ciphertext data block is maintained at the same as the data block length of the plaintext data block.
[0300] The sending unit 604 is configured to send all the encrypted data blocks to the receiving end.
[0301] In another embodiment,
[0302] The encryption unit 603 is configured to randomly generate a second key array and a third key array; wherein the array length of the second key array is the preset processing unit length; the array length of the third key array is determined according to the number of data blocks of the plaintext data segmented from the target plaintext data; and the second key array and the third key array are logically operated on based on a first preset logical operation to obtain the first key array.
[0303] In another embodiment,
[0304] The encryption unit 603 is configured to perform a logical operation on each of the mapped data blocks, based on a second preset logical operation, on the mapped data block and the first key array to generate a ciphertext data block corresponding to the mapped data block.
[0305] In another embodiment,
[0306] The conversion unit 604 is configured to perform conversion for each plaintext data block into a corresponding mapped data block based on the mapping relationship between the plaintext and the ciphertext; wherein the plaintext is an array of sequentially generated integers ranging from 0 to a preset processing unit length minus 1; the ciphertext is a randomly generated array with non-repeating values and an array length equal to the preset processing unit length; the mapping relationship between the plaintext and the ciphertext is such that the element values corresponding to the same index number in the array corresponding to the plaintext and the ciphertext correspond one-to-one.
[0307] This application also provides another data transmission device in its embodiments. See [link to relevant documentation]. Figure 7 , Figure 7 This is a schematic diagram of another data transmission device structure in an embodiment of this application. The data transmission device includes:
[0308] The acquisition unit 701 is configured to acquire a plurality of ciphertext data blocks from the sending end, wherein each ciphertext data block corresponds to a plaintext data block obtained by the sending end from the target plaintext data based on a preset processing unit length, and the data block length of the ciphertext data block is the same as the data block length of the corresponding plaintext data block.
[0309] The decryption unit 702 is configured to use the generated first key array to decrypt each of the ciphertext data blocks to obtain a corresponding mapped data block, wherein the first key array is associated with the number of data blocks of the plaintext data blocks segmented when the sending end generates the ciphertext data blocks, and the data block length of the mapped data block is maintained at the same as the data block length of the plaintext data blocks.
[0310] The conversion unit 703 is configured to perform the conversion of each of the mapped data blocks into the corresponding plaintext data blocks, wherein the conversion mechanism from the mapped data blocks to the plaintext data blocks is the reverse mechanism of the conversion mechanism implemented by the sending end for the plaintext data blocks;
[0311] The concatenation unit 704 is configured to concatenate all the plaintext data blocks in the order in which the corresponding ciphertext data blocks were acquired to obtain the target plaintext data.
[0312] In another embodiment,
[0313] The decryption unit 702 is configured to acquire the second key array and the third key array sent by the sending end; the array length of the second key array is the preset processing unit length; the array length of the third key array is related to the number of plaintext data blocks divided when the sending end generates the ciphertext data block; and the second key array and the third key array are logically operated on based on the first preset logical operation to obtain the first key array.
[0314] In another embodiment,
[0315] The decryption unit 702 is configured to perform a logical operation on each of the ciphertext data blocks, based on a third preset logical operation, to obtain a mapping data block corresponding to the ciphertext data block; wherein the third preset logical operation is the inverse operation of the second preset logical operation.
[0316] In another embodiment,
[0317] The conversion unit 703 is configured to perform conversion for each of the mapped data blocks into a corresponding plaintext data block based on the mapping relationship between plaintext and the ciphertext; wherein the plaintext is an array of sequentially generated integers ranging from 0 to a preset processing unit length minus 1; the ciphertext is a randomly generated array with non-repeating values and an array length equal to the preset processing unit length; the mapping relationship between the plaintext and the ciphertext is such that the element values corresponding to the same index number in the array corresponding to the plaintext and the ciphertext correspond one-to-one.
[0318] The units in the above embodiments can be integrated into one unit or deployed separately; they can be merged into one unit or further divided into multiple sub-units.
[0319] In another embodiment, an electronic device is also provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of a data transmission method.
[0320] In another embodiment, a computer-readable storage medium is also provided, on which computer instructions are stored, which, when executed by a processor, can implement the steps in the data transmission method.
[0321] Figure 8 This is a schematic diagram of the physical structure of an electronic device provided in an embodiment of the present invention. Figure 8 As shown, the electronic device may include a processor 810, a communications interface 820, a memory 830, and a communication bus 840, wherein the processor 810, the communications interface 820, and the memory 830 communicate with each other via the communication bus 840. The processor 810 can call logical instructions in the memory 830 to execute the following methods:
[0322] The target plaintext data is divided into several plaintext data blocks based on a preset processing unit length;
[0323] Each plaintext data block of the target plaintext data is converted into a corresponding mapped data block, wherein the data block length of the mapped data block is kept the same as the data block length of the corresponding plaintext data block;
[0324] Using the generated first key array, each mapped data block is encrypted to obtain the corresponding ciphertext data block. The first key array is associated with the number of data blocks of the plaintext data block obtained by segmenting the target plaintext data, and the length of the ciphertext data block is kept the same as the length of the corresponding plaintext data block.
[0325] Send all encrypted data blocks to the receiving end.
[0326] or,
[0327] Acquire several ciphertext data blocks from the sender, wherein each ciphertext data block corresponds to a plaintext data block obtained by the sender from the target plaintext data based on a preset processing unit length, and the data block length of the ciphertext data block is the same as the data block length of the corresponding plaintext data block;
[0328] Using the generated first key array, each ciphertext data block is decrypted to obtain the corresponding mapped data block. The first key array is associated with the number of plaintext data blocks segmented when the sending end generates the ciphertext data block, and the length of the mapped data block is kept the same as the length of the corresponding plaintext data block.
[0329] Each mapped data block is converted into a corresponding plaintext data block. The conversion mechanism from the mapped data block to the plaintext data block is the reverse mechanism of the conversion mechanism implemented by the sender on the plaintext data block.
[0330] All plaintext data blocks are assembled in the order in which they were obtained from their corresponding ciphertext data blocks to obtain the target plaintext data.
[0331] Furthermore, the logical instructions in the aforementioned memory 830 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0332] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0333] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, 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 can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0334] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments disclosed in this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those shown in the drawings. For example, two blocks shown connectedly may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0335] Those skilled in the art will understand that the features described in the various embodiments and / or claims disclosed in this application can be combined and / or combined in various ways, even if such combinations or combinations are not explicitly described in this application. In particular, without departing from the spirit and teachings of this application, the features described in the various embodiments and / or claims of this application can be combined and / or combined in various ways, and all such combinations and / or combinations fall within the scope of this application.
[0336] This document uses specific embodiments to illustrate the principles and implementation methods of the present invention. The descriptions of these embodiments are merely illustrative of the method and core concepts of the present invention and are not intended to limit this application. Those skilled in the art can make changes to the specific implementation methods and application scope based on the ideas, spirit, and principles of the present invention. Any modifications, equivalent substitutions, or improvements made should be included within the scope of protection of this application.
Claims
1. A data transmission method, characterized in that, The method includes: The target plaintext data is divided into several plaintext data blocks based on a preset processing unit length; Each plaintext data block of the target plaintext data is converted into a corresponding mapped data block, wherein the data block length of the mapped data block is maintained at the same as the data block length of the plaintext data block; Using the generated first key array, each of the mapped data blocks is encrypted to obtain a corresponding ciphertext data block, wherein the first key array is associated with the number of data blocks of the plaintext data blocks obtained by segmenting the target plaintext data, and the data block length of the ciphertext data block is maintained at the same as the data block length of the plaintext data block; Send all the encrypted data blocks to the receiving end; Generating the first key array includes: A second key array and a third key array are randomly generated; wherein the array length of the second key array is the preset processing unit length; and the array length of the third key array is determined according to the number of data blocks of the plaintext data segmented from the target plaintext data. Based on the first preset logical operation, the second key array and the third key array are logically operated on to obtain the first key array; The step of converting each plaintext data block of the target plaintext data into a corresponding mapped data block includes: For each plaintext data block, it is converted into a corresponding mapped data block based on the mapping relationship between the plaintext and the cipherbook; wherein, the plaintext is an array of integers whose values range from 0 to a preset processing unit length minus 1, generated sequentially; the cipherbook is an array of randomly generated values without repetition, and the array length is a preset processing unit length; the mapping relationship between the plaintext and the cipherbook is such that the element values corresponding to the same index number in the arrays corresponding to the plaintext and the cipherbook correspond one-to-one.
2. The method according to claim 1, characterized in that, The step of encrypting each of the mapped data blocks using the generated first key array to obtain the corresponding ciphertext data block includes: For each of the mapped data blocks, a logical operation is performed between the mapped data block and the first key array based on a second preset logical operation to generate a ciphertext data block corresponding to the mapped data block.
3. The method according to claim 1 or 2, characterized in that, The method further includes: A hash value is generated for each plaintext data block segmented based on the target plaintext data; The generated hash value is then sent to the receiving end; wherein the hash value is used by the receiving end to verify whether the data transmission has been tampered with during the data transmission process.
4. A data transmission method, characterized in that, The method includes: Acquire several ciphertext data blocks from the sending end, wherein each ciphertext data block corresponds to a plaintext data block obtained by the sending end from the target plaintext data based on a preset processing unit length, and the data block length of the ciphertext data block is the same as the data block length of the corresponding plaintext data block; Using the generated first key array, each ciphertext data block is decrypted to obtain a corresponding mapping data block. The first key array is associated with the number of plaintext data blocks segmented when the sending end generates the ciphertext data block, and the data block length of the mapping data block is maintained at the same as the data block length of the ciphertext data block. Each of the mapped data blocks is converted into the corresponding plaintext data block, wherein the conversion mechanism from the mapped data block to the plaintext data block is the reverse mechanism of the conversion mechanism implemented by the sending end on the plaintext data block; All the plaintext data blocks are combined in the order in which the corresponding ciphertext data blocks are acquired to obtain the target plaintext data; Generating the first key array includes: Obtain the second key array and the third key array sent by the sending end; the array length of the second key array is the preset processing unit length; the array length of the third key array is related to the number of plaintext data blocks divided by the sending end when generating the ciphertext data block; Based on the first preset logical operation, the second key array and the third key array are logically operated on to obtain the first key array; The step of converting each of the mapped data blocks into the corresponding plaintext data blocks includes: For each of the mapped data blocks, it is converted into a corresponding plaintext data block based on the mapping relationship between plaintext and the codebook; wherein, the plaintext is an array of integers with values from 0 to a preset processing unit length minus 1; the codebook is an array with unique values and an array length of a preset processing unit length; the mapping relationship between the plaintext and the codebook is such that the element values corresponding to the same index number in the arrays corresponding to the plaintext and the codebook correspond one-to-one.
5. The method according to claim 4, characterized in that, The step of decrypting each ciphertext data block using the generated first key array to obtain the corresponding mapped data block includes: For each of the ciphertext data blocks, a logical operation is performed between the ciphertext data block and the first key array based on a third preset logical operation to obtain a mapping data block corresponding to the ciphertext data block; the ciphertext data block is generated based on a logical operation based on a second preset logical operation. The third preset logical operation is the inverse operation of the second preset logical operation.
6. The method according to claim 4 or 5, characterized in that, The method further includes: Obtain the hash value corresponding to the ciphertext data block sent by the sender; Perform a hash calculation on the plaintext data block corresponding to the ciphertext data block to obtain the hash value corresponding to the plaintext data block; Determine whether the hash value corresponding to the ciphertext data block is consistent with the hash value corresponding to the plaintext data block, and verify whether the data has been tampered with during data transmission.
7. A data transmission device, characterized in that, The device includes: The segmentation unit is configured to perform the segmentation of the target plaintext data into several plaintext data blocks based on a preset processing unit length; The conversion unit is configured to convert each plaintext data block of the target plaintext data into a corresponding mapped data block, wherein the data block length of the mapped data block is maintained at the same as the data block length of the plaintext data block. The encryption unit is configured to encrypt each of the mapped data blocks using a generated first key array to obtain a corresponding ciphertext data block, wherein the first key array is associated with the number of data blocks of the plaintext data blocks obtained by segmenting the target plaintext data, and the data block length of the ciphertext data block is maintained at the same as the data block length of the plaintext data block. The sending unit is configured to send all the encrypted data blocks to the receiving end; in, The encryption unit is specifically configured to randomly generate a second key array and a third key array when generating the first key array; wherein the array length of the second key array is the preset processing unit length; the array length of the third key array is determined according to the number of data blocks of the plaintext data blocks into which the target plaintext data is divided; and to perform logical operations on the second key array and the third key array based on a first preset logical operation to obtain the first key array; The conversion unit is specifically configured to convert each plaintext data block into a corresponding mapped data block based on the mapping relationship between the plaintext and the cipherbook; wherein the plaintext is an array of sequentially generated integers ranging from 0 to a preset processing unit length minus 1; the cipherbook is an array of randomly generated non-repeating values with an array length equal to the preset processing unit length; the mapping relationship between the plaintext and the cipherbook is such that the element values corresponding to the same index number in the arrays corresponding to the plaintext and the cipherbook correspond one-to-one.
8. A data transmission device, characterized in that, The device includes: The acquisition unit is configured to acquire a plurality of ciphertext data blocks from the sending end, wherein each ciphertext data block corresponds to a plaintext data block obtained by the sending end from the target plaintext data based on a preset processing unit length, and the data block length of the ciphertext data block is the same as the data block length of the corresponding plaintext data block. The decryption unit is configured to use the generated first key array to decrypt each of the ciphertext data blocks to obtain a corresponding mapped data block, wherein the first key array is associated with the number of data blocks of the plaintext data blocks segmented when the sending end generates the ciphertext data blocks, and the data block length of the mapped data block is maintained at the same as the data block length of the plaintext data blocks. The conversion unit is configured to perform the conversion of each of the mapped data blocks into the corresponding plaintext data blocks, wherein the conversion mechanism from the mapped data blocks to the plaintext data blocks is the reverse mechanism of the conversion mechanism implemented by the sending end on the plaintext data blocks; The concatenation unit is configured to concatenate all the plaintext data blocks in the order in which the corresponding ciphertext data blocks were acquired to obtain the target plaintext data; The decryption unit is further configured to acquire the second key array and the third key array sent by the sending end; the array length of the second key array is the preset processing unit length; the array length of the third key array is related to the number of plaintext data blocks divided when the sending end generates the ciphertext data block; and the second key array and the third key array are logically operated on based on the first preset logical operation to obtain the first key array. The conversion unit is specifically configured to perform conversion for each of the mapped data blocks into a corresponding plaintext data block based on the mapping relationship between plaintext and the cipherbook; wherein, the plaintext is an array of integers with values from 0 to a preset processing unit length minus 1; the cipherbook is an array with unique values and an array length equal to the preset processing unit length; the mapping relationship between the plaintext and the cipherbook is such that the element values corresponding to the same index number in the arrays corresponding to the plaintext and the cipherbook correspond one-to-one.
9. A data transmission system, characterized in that, The system includes: The sending end is configured to divide the target plaintext data into several plaintext data blocks based on a preset processing unit length; convert each plaintext data block of the target plaintext data into a corresponding mapped data block, wherein the data block length of the mapped data block is maintained at the same as the data block length of the plaintext data block; encrypt each mapped data block using a generated first key array to obtain a corresponding ciphertext data block, wherein the first key array is associated with the number of data blocks obtained from the plaintext data block division of the target plaintext data, and the data block length of the ciphertext data block is maintained at the same as the data block length of the plaintext data block; and send all the ciphertext data blocks to the receiving end. The receiving end is configured to acquire a plurality of ciphertext data blocks from the sending end, wherein each ciphertext data block corresponds to a plaintext data block obtained by the sending end from the target plaintext data based on a preset processing unit length, and the data block length of the ciphertext data block is the same as the data block length of the corresponding plaintext data block; using a generated first key array, each ciphertext data block is decrypted to obtain a corresponding mapping data block; each mapping data block is converted into a corresponding plaintext data block, wherein the conversion mechanism from the mapping data block to the plaintext data block is the reverse mechanism of the conversion mechanism implemented by the sending end for the plaintext data block; and all the plaintext data blocks are concatenated according to the acquisition order of the corresponding ciphertext data blocks to obtain the target plaintext data. The sending end generates the first key array, which includes: A second key array and a third key array are randomly generated; wherein the array length of the second key array is the preset processing unit length; and the array length of the third key array is determined according to the number of data blocks of the plaintext data segmented from the target plaintext data. Based on the first preset logical operation, the second key array and the third key array are logically operated on to obtain the first key array; The sending end converts each plaintext data block of the target plaintext data into a corresponding mapped data block, including: For each plaintext data block, it is converted into a corresponding mapped data block based on the mapping relationship between the plaintext and the cipherbook; wherein, the plaintext is an array of integers whose values range from 0 to a preset processing unit length minus 1, generated sequentially; the cipherbook is an array of randomly generated values without repetition, and the array length is a preset processing unit length; the mapping relationship between the plaintext and the cipherbook is such that the element values corresponding to the same index number in the arrays corresponding to the plaintext and the cipherbook correspond one-to-one.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the method as described in any one of claims 1-3 or 4-6.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the program implements the method described in any one of claims 1-3 or 4-6.
Citation Information
Patent Citations
Data encryption method and system
CN104767610A
Data information encryption sending method and device, computer equipment and storage medium
CN111866018A