Data scrambling method and device

By using a permutation table generated by a key to shuffle data segments, the problems of low data transmission efficiency and high complexity in the existing technology are solved, efficient data encryption and decryption are achieved, and quantum computing attacks are prevented.

CN119182550BActive Publication Date: 2025-09-05BEIJING HAITAI FANGYUAN HIGH TECH
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411032238.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-30
Publication Date
2025-09-05
Estimated Expiration
2044-07-30

AI Technical Summary

Technical Problem

During data transmission, existing technologies encrypt data by disrupting the order of data, which increases data processing complexity and reduces transmission efficiency. Especially in the case of large amounts of data, the preprocessing time is long and it is difficult to ensure that the data is correctly reassembled.

Method used

The data segments are shuffled using a permutation table generated based on a key. By obtaining the natural sequence number of each data segment and calculating its second sequence number using the permutation table, data encryption and decryption are achieved, reducing the amount of calculation and improving efficiency.

Benefits of technology

Data encryption and decryption can be quickly completed through the permutation table, which reduces the complexity of data processing and improves transmission efficiency, effectively preventing quantum computing attacks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119182550B_ABST
    Figure CN119182550B_ABST
Patent Text Reader

Abstract

The present application provides a data scrambling method and device, relating to the field of data security technology. The method comprises: obtaining multiple data segments to be processed, and determining a first sequence number for each data segment based on the natural order of each data segment among the multiple data segments; performing scrambling on the multiple data segments based on the first sequence number of each data segment and a permutation table to obtain a second sequence number for each data segment; wherein the permutation table is used to calculate the output order of each data segment in the multiple data segments; and the permutation table is generated based on a key. The data scrambling method and device provided in the present application are used to implement encryption and decryption in the form of data transposition by scrambling the data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data security technology, and in particular to a data disorder method and device. Background Art

[0002] There are many security risks in the data transmission process, including eavesdropping, impersonation, tampering and post-repudiation, which may lead to information leakage, data integrity loss or authentication failure.

[0003] In related technologies, the order of data can be disrupted and sent in an unnatural order to increase the difficulty for attackers to interpret the data.

[0004] However, sending data out of order may increase the complexity of data processing and affect transmission efficiency. When the amount of data is large, the preprocessing time may be long, and the difficulty of ensuring correct data reassembly will also increase. Summary of the Invention

[0005] The purpose of this application is to provide a data scrambling method and device for implementing data encryption and decryption in the form of data transposition by scrambling data.

[0006] This application provides a data shuffling method, comprising:

[0007] Acquire multiple data segments to be processed, and determine a first sequence number for each data segment based on the natural order of each data segment in the multiple data segments; perform scrambling on the multiple data segments based on the first sequence number of each data segment and a permutation table to obtain a second sequence number for each data segment; wherein the permutation table is used to calculate the output sequence and the second sequence number of each data segment in the multiple data segments; the permutation table is generated based on a key.

[0008] In this way, using a permutation table to shuffle data can not only achieve data encryption and decryption, but also greatly reduce the amount of data calculation and improve the efficiency of encryption and decryption.

[0009] Optionally, the performing of random processing on the multiple data segments based on the first sequence number of each data segment and the substitution table to obtain the second sequence number of each data segment includes: obtaining the first sequence number of each data segment in the multiple data segments and the number of data segments in the multiple data segments, and comparing the number of data segments with the number of variables in the substitution table to generate a comparison result; determining the second sequence number of each data segment in the multiple data segments based on the substitution table, the first sequence number of each data segment and the comparison result.

[0010] In this way, after the second sequence number of each data segment is generated by the substitution table, the data segments can be shuffled based on the second sequence number of each data segment, thereby quickly completing the encryption of the original data.

[0011] Optionally, determining the second sequence number of each of the multiple data segments includes: determining a target flag value that matches the first sequence number of the target data segment from the replacement table; the target data segment is: any data segment among the multiple data segments; determining a target sequence number corresponding to the target flag value from the replacement table, and determining the target sequence number as the second sequence number of the target data segment.

[0012] In this way, by using the substitution table lookup method, the flag value that matches the first sequence number of each data segment can be quickly determined, and the second sequence number of each data segment can be further determined from the substitution table based on the flag value, and then the above multiple data segments can be processed in disorder based on the second sequence number.

[0013] Optionally, determining the second sequence number of each data segment in the multiple data segments based on the permutation table and the comparison result includes: when the comparison result indicates that the number of data segments is less than or equal to the number of variables, determining the second sequence number of each data segment based on the permutation table.

[0014] In this way, when the number of data segments is less than or equal to the number of variables in the substitution table, the second sequence number of each data segment can be directly determined according to the substitution table, so that the data segments can be processed in a disorderly manner based on the second sequence number of each data segment, thereby quickly completing the encryption of the original data.

[0015] Optionally, determining the second sequence number of each data segment based on the permutation table and the comparison result includes: when the comparison result indicates that the number of data segments is greater than the number of variables, and the first sequence number of the current data segment is less than or equal to the number of variables, determining the temporary sequence number of the current data segment based on the permutation table.

[0016] Optionally, determining the second sequence number of each data segment based on the substitution table and the comparison result includes: when the comparison result indicates that the number of data segments is greater than the number of variables, and the first sequence number of the current data segment is greater than the number of variables, calculating the flag value corresponding to the current data segment based on the first sequence number of the current data segment using a preset flag value calculation method; screening out from the sorted data segments the data segment with the same number to be adjusted as the flag value corresponding to the current data segment, and using the temporary sequence number of the data segment with the number to be adjusted as the second sequence number of the current data segment; wherein the sorted data segment is: the data segment with a determined temporary sequence number among the multiple data segments.

[0017] In this way, in the case where the number of data segments is greater than the number of variables, a preset flag value calculation method can be used to calculate the flag value of the data segments that exceed the number of variables, and the data segments with the same temporary sequence number as the flag value in the sorted data segments can be replaced according to the flag value, thereby realizing the disorder processing of each data segment in the above multiple data segments, and then realizing the rapid encryption of the original data.

[0018] Optionally, the second sequence number of each data segment is determined based on the substitution table and the comparison result, and the method also includes: when there is no data segment with an undetermined temporary sequence number and no data segment with an undetermined second sequence number in the multiple data segments, the temporary sequence number corresponding to each data segment in the data segments with an undetermined second sequence number is determined as the second sequence number of each data segment.

[0019] Optionally, the preset flag value calculation method includes: extracting a preset number of bits from the key as the initial value of the memory unit; the number of bits stored in the memory unit is equal to the length of a long integer; and calculating the flag value corresponding to each data segment based on the state update of the memory unit; wherein, the state update of the memory unit includes: inputting the lower n bits of the memory unit into the substitution table to obtain the flag value corresponding to the current data segment; the state update of the memory unit also includes: inputting the flag value corresponding to the current data segment into the substitution table to obtain a first result value; performing an XOR operation on the first result value and the first sequence number corresponding to the current data segment to obtain a second result value; performing an XOR operation on the second result value and the memory unit to obtain a third result value; performing a bit shift operation on the third result value, and cyclically shifting the third result value right by m bits to obtain a fourth result value; and updating the state of the memory unit based on the fourth result value; n is the number of bits of the input data and output data of the substitution table, and m is a number that cannot be divided evenly by 64.

[0020] The present application also provides a data scrambling device, comprising:

[0021] A data processing module is used to obtain multiple data segments to be processed and determine the first sequence number of each data segment based on the natural order of each data segment among the multiple data segments; a data scrambling module is used to perform scrambling processing on the multiple data segments based on the first sequence number of each data segment and a substitution table to obtain the second sequence number of each data segment; wherein the substitution table is used to calculate the output sequence and the second sequence number of each data segment in the multiple data segments; the substitution table is generated based on a key.

[0022] Optionally, the data processing module is further used to obtain the first sequence number of each data segment in the multiple data segments and the number of data segments in the multiple data segments; the comparison module is used to compare the number of data segments with the number of variables in the substitution table to generate a comparison result; the data disorder module is specifically used to determine the second sequence number of each data segment in the multiple data segments based on the substitution table, the first sequence number of each data segment and the comparison result.

[0023] Optionally, the data shuffling module is specifically used to determine a target flag value that matches the first sequence number of the target data segment from the replacement table; the target data segment is: any data segment among the multiple data segments; the data shuffling module is also specifically used to determine a target sequence number corresponding to the target flag value from the replacement table, and determine the target sequence number as the second sequence number of the target data segment.

[0024] Optionally, the data shuffling module is specifically configured to determine a second sequence number for each data segment based on the substitution table when the comparison result indicates that the number of data segments is less than or equal to the number of variables.

[0025] Optionally, the data shuffling module is specifically used to determine the temporary sequence number of the current data segment based on the substitution table when the comparison result indicates that the number of data segments is greater than the number of variables and the first sequence number of the current data segment is less than or equal to the number of variables.

[0026] Optionally, the data shuffling module is specifically used to calculate the flag value corresponding to the current data segment based on the first sequence number of the current data segment using a preset flag value calculation method when the comparison result indicates that the number of data segments is greater than the number of variables and the first sequence number of the current data segment is greater than the number of variables; the data shuffling module is also specifically used to filter out the data segment with the same number to be adjusted as the flag value corresponding to the current data segment from the sorted data segments, and use the temporary sequence number of the data segment with the number to be adjusted as the second sequence number of the current data segment; wherein the sorted data segment is: a data segment with a determined temporary sequence number among the multiple data segments.

[0027] Optionally, the data disorder module is specifically used to determine the temporary sequence number corresponding to each data segment in the data segments with undetermined second sequence numbers as the second sequence number of each data segment when there is no data segment with undetermined temporary sequence number and no data segment with undetermined second sequence number in the multiple data segments.

[0028] Optionally, the device also includes: a generation module; the generation module is used to intercept a value of a preset number of bits from the key as the initial value of the memory unit; the number of bits stored in the memory unit is equivalent to the length of the long integer; the generation module is also used to calculate the flag value corresponding to each data segment based on the state update of the memory unit; wherein the state update of the memory unit includes: inputting the lower n bits of the memory unit into the substitution table to obtain the flag value corresponding to the current data segment; the state update of the memory unit also includes: inputting the flag value corresponding to the current data segment into the substitution table to obtain a first result value; performing an XOR operation on the first result value and the first sequence number corresponding to the current data segment to obtain a second result value; performing an XOR operation on the second result value and the memory unit to obtain a third result value; performing a bit shift operation on the third result value, and cyclically shifting the third result value right by m bits to obtain a fourth result value; updating the memory unit based on the fourth result value; n is the number of bits of the input data and output data of the substitution table, and m is a number that cannot be divided evenly by 64.

[0029] The present application also provides a computer program product, comprising a computer program or instructions, which implements the steps of any of the above-mentioned data scrambling methods when executed by a processor.

[0030] The present application also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any of the above-described data scrambling methods when executing the program.

[0031] The present application also provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of any of the above-mentioned data scrambling methods are implemented.

[0032] The data scrambling method and device provided by the present application first obtains multiple data segments to be processed and determines a first sequence number for each data segment based on its natural order within the multiple data segments. Subsequently, the multiple data segments are scrambled based on the first sequence number and a permutation table to obtain a second sequence number for each data segment. The permutation table is used to calculate the output order and second sequence number of each data segment in the multiple data segments, and the permutation table is generated based on a key. In this way, data encryption and decryption can be achieved by scrambling the data. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] In order to more clearly illustrate the technical solutions in the present application or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0034] Figure 1 This is a flow chart of the data scrambling method provided by this application;

[0035] Figure 2 It is a structural diagram of the data scrambling device provided by this application;

[0036] Figure 3 It is a structural diagram of the electronic device provided in this application. DETAILED DESCRIPTION

[0037] To make the objectives, technical solutions, and advantages of this application more clear, the technical solutions of this application will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments of this application, all other embodiments obtained by ordinary technicians in this field without making any creative efforts are within the scope of protection of this application.

[0038] The terms "first," "second," and the like in the specification and claims of this application are used to distinguish similar objects, and are not used to describe a specific order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, so that the embodiments of this application can be implemented in an order other than that illustrated or described herein, and that the objects distinguished by "first," "second," and the like are generally of the same type, and do not limit the number of objects; for example, the first object can be one or more. In addition, the term "and / or" in the specification and claims refers to at least one of the connected objects, and the character " / " generally indicates that the objects connected are in an "or" relationship.

[0039] In certain scenarios of privacy-preserving computing, particularly during the intersection of datasets, the conclusion after the computation may be either yes or no, or simply determine the number of data, without regard to the specific location or form of the data. Furthermore, the results may not be known to other parties. During data exchange, Party A transmits a batch of data consisting of multiple data segments to Party B. Party B is required to perform some form of encryption on each data segment and return the encrypted ciphertext to Party A. However, Party A may be curious, or even dishonest or malicious. By matching each plaintext data segment with a ciphertext data segment and studying the patterns of change between the plaintext and ciphertext, Party A may be able to uncover Party B's encryption algorithm or obtain Party B's key.

[0040] To prevent this type of "data input and output correspondence" attack by Party A or a third party eavesdropping on the channel, a simple and practical method is for Party B to shuffle the output. Specifically, Party B rearranges the multiple data segments according to a secret rule and outputs them one by one in the new order. If the number of data segments is fixed at N, a secret N-ary permutation table can be set up, and Party B can simply send the corresponding data segments one by one according to the order in which the elements in the table appear. However, if the number of data segments is uncertain and changes frequently, using a large permutation table to shuffle the data may not be suitable.

[0041] The Diffie-Hellman (DH) key agreement protocol is an efficient and practical key agreement method. However, it is not resistant to quantum computing attacks. During a DH key agreement with a modulus size of 2048 bits, both parties need to send and receive data of 2048 bits (256 bytes). If both parties had a shared data scrambling method, and each party scrambled the 256 bytes each time according to this method, quantum computing attacks would be resilient as long as the scrambling method varied sufficiently. For example, if each data segment is 8 bits long, 256 bytes can be permuted in up to 256 different ways.

[0042] The data reordering method provided in the embodiment of the present application is described in detail below with reference to the accompanying drawings through specific embodiments and their application scenarios.

[0043] like Figure 1 As shown, an embodiment of the present application provides a data shuffling method, which may include the following steps 101 and 102:

[0044] Step 101: Acquire multiple data segments to be processed, and determine a first sequence number for each data segment based on a natural ordering of each data segment among the multiple data segments.

[0045] For example, the multiple data segments mentioned above may be data segments that need to be sent and received by two parties. In an embodiment of the present application, the sender can shuffle the multiple data segments using a permutation table before sending the data to the receiver. The receiver can then restore the shuffled data based on the permutation table, thereby obtaining the original order of the multiple data segments and restoring them to the complete data. Alternatively, the sender may not want the receiver to know the order of the data segments, so that only the sender can restore the original order.

[0046] Step 102: Perform shuffling on the plurality of data segments based on the first sequence number of each data segment and a substitution table to obtain a second sequence number of each data segment;

[0047] In which, the permutation table is used to calculate the output order and second sequence number of each data segment in the multiple data segments; the permutation table is generated based on a key; the first sequence number of the data segment is calculated based on the natural order of the data segment in the multiple data segments.

[0048] Exemplarily, after acquiring the plurality of data segments, the plurality of data segments are shuffled using the substitution table to disrupt the arrangement order of the plurality of data segments, thereby obtaining second sequence numbers of the plurality of data segments.

[0049] For example, Party B selects a private permutation table. This table could be a 256-element table with 8-bit input and 8-bit output, a 16-element table with 4-bit input and 4-bit output, a 64-element table with 6-bit input and 6-bit output, or any arbitrary number of variables that is not a power of 2. The size of the permutation table, i.e., the number of variables in the table, can be determined based on multiple factors, including security requirements, cache capacity, and latency requirements.

[0050] For example, taking the above permutation table as a 16-element permutation table (ie, N=16), the above permutation table may be shown in the following Table 1:

[0051]

[0052] Table 1

[0053] Exemplarily, the meaning of the substitution table shown in Table 1 above is: when the sequence number of a data segment among the above multiple data segments is 1, the sequence number of the data segment after shuffling is 9; when the sequence number of a data segment among the above multiple data segments is 2, the sequence number of the data segment after shuffling is 7.

[0054] Specifically, the above step 102 may further include the following steps 102a and 102b:

[0055] Step 102a: Obtain the first sequence number of each data segment in the multiple data segments and the number of data segments in the multiple data segments, and compare the number of data segments with the number of variables in the substitution table to generate a comparison result.

[0056] Step 102b: Determine a second sequence number for each of the multiple data segments based on the substitution table, the first sequence number of each data segment, and the comparison result.

[0057] Exemplarily, the first sequence number is obtained based on the natural ordering of the data segments among the plurality of data segments. Exemplarily, the first sequence number may be the same as the original sequence number corresponding to the natural ordering of the data segments, or may be obtained by performing a calculation based on the original sequence number. The second sequence number is the sequence number obtained by shuffling the plurality of data segments using a permutation table.

[0058] Specifically, in the above step 102b, the step of determining the second sequence number of each data segment may further include the following steps 102b1 and 102b2:

[0059] Step 102b1: Determine a target flag value that matches the first sequence number of the target data segment from the substitution table.

[0060] The target data segment is any one of the multiple data segments. That is, for each of the multiple data segments, its corresponding second sequence number can be calculated according to step 102b1 and step 102b2.

[0061] Step 102b2: Determine the target sequence number corresponding to the target flag value from the replacement table, and determine the target sequence number as the second sequence number of the target data segment.

[0062] Exemplarily, for any target data segment among the above-mentioned multiple data segments, it is necessary to match the corresponding flag value (i.e., the number of the first row in the above Table 1) in the substitution table through its first sequence number, and then determine the second sequence number of the target data segment through the flag value.

[0063] Illustratively, after determining the second sequence number of each data segment through the above-mentioned substitution table, the data can be sent to the receiver according to the second sequence number of each data segment to achieve out-of-order processing and sending of data.

[0064] Optionally, in an embodiment of the present application, different out-of-order processing methods may be executed based on a comparison result of the number of data segments and the number of variables in the substitution table.

[0065] Exemplarily, in an embodiment of the present application, there are two cases: the number of data segments is less than or equal to the number of variables in the substitution table, and the number of data segments is greater than the number of variables in the substitution table. Different out-of-order processing can be performed for these two cases respectively.

[0066] Case 1:

[0067] In case 1, the number of data segments is less than or equal to the number of variables in the substitution table.

[0068] Specifically, the above step 102b may further include the following step 102b3:

[0069] Step 102b3: When the comparison result indicates that the number of data segments is less than or equal to the number of variables, determine a second sequence number for each data segment based on the substitution table.

[0070] Exemplarily, when the number of data segments is less than or equal to the number of variables in the permutation table, the permutation table can be directly used to reorder each data segment.

[0071] For example, if there are 16 or fewer data segments, send each segment in the order shown in the table. For example, if there are only 11 data segments, number them 1, 2, 3, ..., 11. The permutation table then shows that segment 9 should be sent first, followed by segments 7 and 3. When segment 14 is needed, it is skipped because there is no segment with that number. Similarly, segments 15 and 16 are skipped, and so on.

[0072] It should be noted that when the number of data segments is small, for example, there are 7 data segments in total, no matter how Party B disrupts the order of the data segments, the total number of possible arrangements will not exceed 7! = 5040. It is unrealistic to rely on disrupting the order to prevent unauthorized persons from obtaining the correct data. However, when there are 20 data segments, the change reaches 20! = 2432902008176640000 ≈ 2 61, it becomes somewhat difficult for unauthorized persons to obtain the correct data. This difficulty increases as the number of data segments increases. Therefore, Party B can disrupt the order of the data segments to prevent attacks by Party A or third-party attackers based on the known data input and output correspondence.

[0073] Case 2:

[0074] In case 2, the number of data segments is greater than the number of variables in the substitution table.

[0075] Exemplarily, for data segments whose first sequence numbers are less than or equal to the number of variables, the second sequence numbers of these data segments can be determined in the same processing method as step 102b3.

[0076] Specifically, the above step 102b may further include the following step 102b4:

[0077] Step 102b4: When the comparison result indicates that the number of data segments is greater than the number of variables, and the first sequence number of the current data segment is less than or equal to the number of variables, determine the temporary sequence number of the current data segment based on the substitution table.

[0078] For example, since the sequence number of each data segment determined in the above step 102b4 is not necessarily the final second sequence number, the sequence number of the data segment determined in step 102b4 is represented here by a temporary sequence code.

[0079] Exemplarily, for a data segment whose first sequence number is greater than the number of variables, a random number less than or equal to the number of variables can be generated, and the second sequence number of this data segment can be determined based on the random number.

[0080] Specifically, after the above step 102b4, the above step 102b may further include the following steps 102b5 and 102b6:

[0081] Step 102b5: When the comparison result indicates that the number of data segments is greater than the number of variables, and the first sequence number of the current data segment is greater than the number of variables, a preset flag value calculation method is used to calculate the flag value corresponding to the current data segment based on the first sequence number of the current data segment.

[0082] Step 102b6: Filter out the data segments to be adjusted whose number has the same flag value as that of the current data segment from the sorted data segments, and use the temporary sequence number of the data segments to be adjusted as the second sequence number of the current data segment.

[0083] The sorted data segments are data segments with determined temporary sequence numbers among the multiple data segments.

[0084] Illustratively, the processed data segment is the data segment for which the temporary sequence number has been determined in step 102b4. For a data segment whose first sequence number is greater than the number of variables in the transposition table, a flag value corresponding to the current data segment can be calculated using a preset flag value calculation method. The sorted data segment corresponding to the flag value is then extracted and transmitted or stored, and the temporary sequence number corresponding to the flag value is then assigned to the current data segment.

[0085] For example, based on Table 1, if there are more than 16 data segments, the first 16 data segments are not sent when they are arranged. Instead, the data segments numbered 1 to 16 are placed in registers numbered 9, 7, 3, 14, ..., 5, in order according to the above permutation table. When processing data segments 17 and later, a positive integer between 1 and 16 is generated using a preset flag value calculation method. This number is called the flag value, and the permutation table is searched based on this flag value to determine the output position. For example, if the 17th data segment (number 17) is obtained and the flag value is calculated to be 9, then the permutation table is searched for 10, and the data segment stored in register 10 (i.e., the original data segment numbered 13) is sent or output, and the resulting data segment numbered 17 is placed in register 10. After that, the 18th data segment is processed and its flag value is calculated. Assuming the calculated flag value is 5, the permutation table is searched for 5 and the result is 11. Therefore, the data segment stored in register 11 (i.e., the original number 1) is sent, and the (18th) data segment numbered 18 is placed in register 11. Next, the 19th data segment is encrypted. Assuming the calculated flag value is 5, the permutation table is searched for 5 and the result is 11. Therefore, the data segment stored in register 11 (i.e., the number 18 just placed) is sent, and the newly generated encrypted data segment numbered 19 is placed in register 11. After processing all the data segments, the 16 data segments in the registers are sent one by one in order from 1 to 16 (or in reverse order). For example, if there are only 19 data segments in total, the data numbers stored in registers numbered 1 to 16 after processing the 19th data segment are shown in Table 2:

[0086]

[0087] Table 2

[0088] According to Table 2 above, the data segments corresponding to the flag values ​​10 and 11 have been sent (or output) in the replacement order, and the data segments corresponding to the flag values ​​10 and 11 after replacement are the data segments with the first sequence numbers 17 and 19 respectively.

[0089] It's important to note that if a permutation table of N elements is used, the initial permutation must be numbered from 1 to N, and the calculated flag value should also be an integer between 1 and N. For example, N can be 10, 26, 49, 64, and so on. The larger the value of N, the greater the uncertainty in the resulting permutation. If occupying too many temporary storage locations is undesirable, or if delaying transmission is unacceptable during online operations, a smaller number of variables N can be used.

[0090] In one possible implementation, the data segment does not participate in the calculation of the flag value, and the flag value can be obtained by setting an initial value X and calculating with the initial value X. For example, the flag value can be calculated using the following formula 1:

[0091] Y=X 3 +13X+29 mod N (Formula 1)

[0092] Among them, Y+1 is the mark value. Every time the second sequence number of a data segment is generated, the value of X increases by 1. This disorder process can be reproduced in reverse to facilitate the restoration of the original order.

[0093] In another possible implementation, the data segment is used to calculate the flag value. The data segment consists of multiple bytes. For example, only the first byte of the data segment is used to calculate the flag value. The value of this byte is denoted as b. An initial value X is set, and the flag value is calculated with the initial value X. For example, the flag value can be calculated using the following formula 2:

[0094] Y=X 3 +bX+b3 mod N (Formula 2)

[0095] Among them, Y+1 is the flag value. Every time the second sequence number of a data segment is generated, the value of X increases by 1. This solution can achieve a better disorder effect, but it may be inconvenient to restore the original order.

[0096] Illustratively, after the order of all data segments is determined, the multiple data segments may be reordered to obtain the second data.

[0097] Specifically, after step 102b6, step 102b may further include the following steps 102b7 and 102b8:

[0098] Step 102b7: reorder the data segments in the set of data segments to be out of order according to the second sequence number of each data segment in the set of data segments to be out of order, to obtain third data.

[0099] Step 102b8: Add the third data to the end of the intermediate data by appending to obtain the second data.

[0100] For example, the order of the replaced data segments has been determined, and then the remaining data segments can be reordered according to the second sequence number of each data segment in the remaining data segments.

[0101] It is understood that after setting the key, parameter N, and flag value calculation rules, an N-ary permutation table is derived from the key. If the number of data segments to be shuffled is no more than N, the order specified in the permutation table is followed. If the number of data segments is greater than N, the data is output and buffered simultaneously. This can be applied to any amount of data, and the other party who shares the key, parameter N, and flag value calculation rules can restore the shuffled order to the original order.

[0102] Optionally, in an embodiment of the present application, the above substitution table can be calculated in the following manner.

[0103] Illustratively, before step 102, the data shuffling method provided in the embodiment of the present application may further include the following steps 103 and 104:

[0104] Step 103: obtain the N key control characters after deriving the key, create a pending substitution table containing N flag values ​​based on the number of bytes of the key control characters, and initialize the second sequence number and first parameter corresponding to each flag value in the pending substitution table.

[0105] Step 104: Repeat the cumulative calculation on the first parameter, and adjust the second sequence number corresponding to each flag value in the to-be-processed substitution table according to the result of the cumulative calculation to obtain the substitution table.

[0106] The cumulative calculation includes: calculating the key control symbol of the current round and the round number of the current round, performing an arithmetic or logical operation (including: a modular operation, an accumulation operation, and an exclusive OR operation, etc.), adding the calculation result to the second sequence number of the current round, and then performing a modular operation on N to obtain a second parameter, performing a modular operation on N with the value obtained by accumulating the second parameter and the first parameter, and using the modular operation result to update the first parameter.

[0107] For example, taking the generation of a 256-element substitution table as an example, assuming that the key length is n bytes, usually n<256, the key can be derived into N=256 characters by cyclic filling, recorded as KW0, KW1, KW2, ..., KW 255 The following method can be used to generate a 256-element permutation table:

[0108] 1. Set the initial value for the permutation table. For example, for i = 0, 1, 2, ..., 255, calculate s[i] = i ⊕ 0x55. The “⊕” represents bitwise XOR calculation. Thus, s[0], s[1], ..., s

[255] stores a permutation of { 0, 1, ..., 255}.

[0109] 2. The key control words KW0, KW1, KW2, ..., KW 255 Stored in k[0]-k

[255] .

[0110] 3. Let the first parameter x and the second parameter y be temporary working units, and set the initial value x=255.

[0111] 4. Perform the following transformations for i = 0, 1, 2, …, 255: a) Calculate y = s[i] + (k[i] ⊕ i) mod 256; b) Add y to the x cell and increase x modulo 256. That is, x + y mod 256 → x; c) Based on the values ​​of i and x, swap the value stored in s[i] with the value stored in s[x].

[0112] 5. Use the final obtained s[0]-s

[255] as a 256-element permutation table with 8-bit input and 8-bit output.

[0113] It should be noted that in the above transformation, the number of key control words can be more or less than the number of elements in the S-box and does not have to be exactly 256. The derived key characters KW0, KW1, KW2, ... can also be 7-, 6-, 5-, or 4-bit characters, used to generate 128-, 64-, 32-, and 16-bit permutation tables, respectively.

[0114] It should be noted that the data scrambling method in the embodiments of the present application can be used not only for data transmission but also for data storage. Specifically, the data scrambling method provided in the embodiments of the present application can be used to scramble data and then encrypt and store it. When the data needs to be read, the data segments can be restored to their original order. This can prevent others from unauthorized copying and use of certain data files.

[0115] In another possible implementation, the data segment is not involved in the calculation of the flag value. Assuming the user key is an N-bit random number, for example, N = 128 or 256 bits, a 6-input, 6-output permutation table is generated using some of the key bits. Subsequently, some of the key bits are used to initialize the initial state of the 32-bit or 64-bit memory unit R, and the flag value corresponding to the data segment is calculated based on R.

[0116] Specifically, the method for calculating the preset flag value in step 102 may further include the following steps 102c1 and 102c2:

[0117] Step 102c1: extract a random number of preset bits from the key as the initial value of the memory unit.

[0118] The number of bits stored in the memory unit is equal to the length of an integer of the same length, which is generally 64 or 32 bits.

[0119] Step 102c2: Calculate the flag value corresponding to each data segment based on the memory unit state update method.

[0120] Among them, the memory unit state update method includes: inputting the lower n bits of the memory unit into the substitution table to obtain the flag value corresponding to the current data segment; the memory unit state update method also includes: inputting the flag value corresponding to the current data segment into the substitution table to obtain a first result value; performing an XOR operation on the first result value and the first sequence number corresponding to the current data segment to obtain a second result value; performing an XOR operation on the second result value and the memory unit value to obtain a third result value; performing a shift operation on the third result value, cyclically shifting the third result value right by m bits to obtain a fourth result value; updating the memory unit based on the fourth result value; n is the number of bits of input data and output data of the substitution table. In order to prevent segmentation analysis, the number of right shift bits m is usually not divisible by 64.

[0121] For example, assume the user key is an N-bit random number, say N = 128 or 256 bits. Use the first N bits to generate a 6-in, 6-out permutation table. Use a specific 32-bit (or 64-bit) portion of the key as the initial state of register R (the aforementioned memory unit), where R is a 32-bit (or 64-bit) unsigned integer. For time steps i = 0, 1, 2, ... (i.e., the first sequential number of the current data segment), perform the following calculation:

[0122] 1. Calculate K i =S(R&63), K i As the 6-bit flag value outputted at the i-th beat (the K i (where "R&63" represents the low-order 6 bits of R, equivalent to taking the 32-bit (or 64-bit) number R modulo 64.) S is the step of looking up a permutation table, which replaces one value with another.

[0123] 2. Calculate tmp = R⊕(i⊕S(K i )), R=tmp>>>6. When performing the XOR operation “⊕”, i and Ki are regarded as 32 (or 64) bits (when i≥2 32 Time Mode 2 32 , only take the remainder, or when i ≥ 2 in 64-bit operation 64 Time Mode 2 64), where ">>>6" is a 6-bit circular right shift of a 32-bit (or 64-bit) number. A circular right shift means that the bit shifted out from the lowest bit on the right is returned to the highest bit.

[0124] Since the timing beat value i participates in the shift register state change, the period of the flag value sequence K= (K0, K1, K2, ...) is not less than 2 32 (or 2 64 ).

[0125] For example, the above steps assume that a 6-bit random number is generated each time. If an 8-bit random number needs to be generated each time, an 8-input 8-output permutation table can be used, and an 8-bit random number can be generated each time after looking up the permutation table. The above scheme for generating 6-bit random numbers can be changed to generate 8 bits each time. That is, an 8-input 8-output permutation table is determined by the key, and the loop count value i is a 64-bit unsigned long integer. For the timing beat i = 0, 1, 2, ..., the following calculation is performed:

[0126] 1. Calculate K i =S(R&255). K i The 8-bit flag value output as the i-th beat. "R&255" means taking the lower 8 bits of R, which is equivalent to modulo 256.

[0127] 2. Calculate tmp = R⊕(i⊕S(K i )), R=tmp>>>9. When the XOR operation “⊕” is performed, i and K i is considered as a 64-bit number (when i ≥ 2 64 Time Mode 2 64 ), where ">>>9" is a circular right shift of a 64-bit number by 9 bits. Because 9 and 64 are relatively prime, a circular right shift of 9 bits provides better performance.

[0128] Since the 64-bit timing beat value i participates in the shift register state change, it can be guaranteed that the period of the flag value sequence K= (K0, K1, K2, ...) is not less than 2 64 .

[0129] The data scrambling method provided in an embodiment of the present application first obtains multiple data segments to be processed and determines a first sequence number for each data segment based on its natural order within the multiple data segments. Subsequently, the multiple data segments are scrambled based on the first sequence number and a permutation table to obtain a second sequence number for each data segment. The permutation table is used to calculate the output order and second sequence number of each data segment in the multiple data segments, and the permutation table is generated based on a key. In this way, data encryption and decryption can be achieved by scrambling the data.

[0130] It should be noted that the data scrambling method provided in the embodiments of the present application can be executed by a data scrambling device or a control module in the data scrambling device for executing the data scrambling method. In the embodiments of the present application, the data scrambling device executing the data scrambling method is used as an example to illustrate the data scrambling device provided in the embodiments of the present application.

[0131] It should be noted that in the embodiments of the present application, the data scrambling methods shown in the figures of the above-mentioned methods are all illustrated by way of example in conjunction with one of the figures in the embodiments of the present application. In specific implementation, the data scrambling methods shown in the figures of the above-mentioned methods can also be implemented in conjunction with any other combinable figures shown in the above-mentioned embodiments, and will not be further described here.

[0132] The data shuffling device provided by the present application is described below, and the data shuffling method described below can be referenced to each other.

[0133] Figure 2 A schematic diagram of the structure of the data disorder device provided in the embodiment of the present application is shown as follows: Figure 2 As shown, specifically including:

[0134] The data processing module 201 is used to obtain multiple data segments to be processed and determine the first sequence number of each data segment based on the natural order of each data segment among the multiple data segments; the data scrambling module 202 is used to perform scrambling processing on the multiple data segments based on the first sequence number of each data segment and a substitution table to obtain the second sequence number of each data segment; wherein the substitution table is used to calculate the output sequence and the second sequence number of each data segment in the multiple data segments; the substitution table is generated based on a key.

[0135] Optionally, the data processing module 201 is further used to obtain the first sequence number of each data segment in the multiple data segments and the number of data segments in the multiple data segments; the comparison module is used to compare the number of data segments with the number of variables in the substitution table to generate a comparison result; the data disorder module 202 is specifically used to determine the second sequence number of each data segment in the multiple data segments based on the substitution table, the first sequence number of each data segment and the comparison result.

[0136] Optionally, the data shuffling module 202 is specifically used to determine a target flag value that matches the first sequence number of the target data segment from the replacement table; the target data segment is: any data segment among the multiple data segments; the data shuffling module 202 is also specifically used to determine a target sequence number corresponding to the target flag value from the replacement table, and determine the target sequence number as the second sequence number of the target data segment.

[0137] Optionally, the data shuffling module 202 is specifically configured to determine a second sequence number for each data segment based on the substitution table when the comparison result indicates that the number of data segments is less than or equal to the number of variables.

[0138] Optionally, the data shuffling module 202 is specifically used to determine the temporary sequence number of the current data segment based on the substitution table when the comparison result indicates that the number of data segments is greater than the number of variables and the first sequence number of the current data segment is less than or equal to the number of variables.

[0139] Optionally, the data shuffling module 202 is specifically used to calculate the flag value corresponding to the current data segment based on the first sequence number of the current data segment using a preset flag value calculation method when the comparison result indicates that the number of data segments is greater than the number of variables and the first sequence number of the current data segment is greater than the number of variables; the data shuffling module 202 is also specifically used to filter out the data segment with the same number to be adjusted as the flag value corresponding to the current data segment from the sorted data segments, and use the temporary sequence number of the data segment with the number to be adjusted as the second sequence number of the current data segment; wherein the sorted data segment is: a data segment with a determined temporary sequence number among the multiple data segments.

[0140] Optionally, the data disorder module 202 is specifically used to determine the temporary sequence number corresponding to each data segment in the data segments with undetermined second sequence numbers as the second sequence number of each data segment when there is no data segment with undetermined temporary sequence numbers and no data segment with undetermined second sequence numbers in the multiple data segments.

[0141] Optionally, the device further includes a generation module; the generation module is used to intercept a value of a preset number of bits from the key as the initial value of the memory unit; the number of bits stored in the memory unit is equivalent to the length of the long integer; the generation module is also used to calculate the flag value corresponding to each data segment based on the state update of the memory unit; wherein, the update of the memory unit state includes: inputting the lower n bits of the memory unit into the substitution table to obtain the flag value corresponding to the current data segment; the memory unit state update also includes: inputting the flag value corresponding to the current data segment into the substitution table to obtain a first result value; performing an XOR operation on the first result value and the first sequence number corresponding to the current data segment to obtain a second result value; performing an XOR operation on the second result value and the memory unit to obtain a third result value; performing a bit shift operation on the third result value, and cyclically shifting the third result value right by m bits to obtain a fourth result value; updating the memory unit based on the fourth result value; n is the number of bits of the input data and output data of the substitution table, and m is a number that cannot be divided evenly by 64.

[0142] The data scrambling device provided by the present application first obtains multiple data segments to be processed and determines a first sequence number for each data segment based on the natural order of the data segments in the multiple data segments. Then, the multiple data segments are scrambled based on the first sequence number of each data segment and a permutation table to obtain a second sequence number for each data segment. The permutation table is used to calculate the output order and second sequence number of each data segment in the multiple data segments. The permutation table is generated based on a key. In this way, data encryption and decryption can be achieved by scrambling the data.

[0143] Figure 3 An example of a physical structure diagram of an electronic device is shown below. Figure 3 As shown, the electronic device may include: a processor 310, a communication interface 320, a memory 330 and a communication bus 340, wherein the processor 310, the communication interface 320 and the memory 330 communicate with each other via the communication bus 340. The processor 310 may call the logic instructions in the memory 330 to execute a data scrambling method, which includes: obtaining a plurality of data segments to be processed, and determining a first sequence number of each data segment based on the natural order of each data segment in the plurality of data segments; performing scrambling processing on the plurality of data segments based on the first sequence number of each data segment and a permutation table to obtain a second sequence number of each data segment; wherein the permutation table is used to calculate the output sequence and the second sequence number of each data segment in the plurality of data segments; and the permutation table is generated based on a key.

[0144] In addition, the logical instructions in the above-mentioned memory 330 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present application, or the part that contributes to the existing technology, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program code.

[0145] On the other hand, the present application also provides a computer program product, which includes a computer program stored on a computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the data scrambling method provided by the above methods, the method including: obtaining multiple data segments to be processed, and determining the first sequence number of each data segment based on the natural order of each data segment among the multiple data segments; performing scrambling processing on the multiple data segments based on the first sequence number of each data segment and a substitution table to obtain the second sequence number of each data segment; wherein the substitution table is used to calculate the output sequence and second sequence number of each data segment in the multiple data segments; the substitution table is generated based on a key.

[0146] On the other hand, the present application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to perform the above-mentioned data scrambling methods, the method comprising: obtaining multiple data segments to be processed, and determining a first sequence number of each data segment based on the natural order of each data segment among the multiple data segments; performing scrambling processing on the multiple data segments based on the first sequence number of each data segment and a permutation table to obtain a second sequence number of each data segment; wherein the permutation table is used to calculate the output sequence and second sequence number of each data segment in the multiple data segments; the permutation table is generated based on a key.

[0147] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they may be located in one location or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.

[0148] Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented using software plus a necessary general-purpose hardware platform, or of course, hardware. Based on this understanding, the essence of the above technical solution, or the portion 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, a magnetic disk, or an optical disk, and includes a number of instructions for causing a computer device (such as a personal computer, server, or network device) to execute the methods described in each embodiment or certain portions of the embodiments.

[0149] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A data disorder method, characterized in that: Applied to the field of data security, the method includes: Obtaining a plurality of data segments to be sent, and determining a first sequence number for each data segment based on a natural ordering of each data segment in the plurality of data segments; Performing shuffling processing on the multiple data segments based on the first sequence number of each data segment and the substitution table to obtain a second sequence number of each data segment, and after performing shuffling processing on the multiple data segments based on the second sequence number of each data segment, sending the multiple data segments to a receiver; The permutation table is used to calculate the output sequence and the second sequence number of each data segment in the plurality of data segments; the permutation table is generated based on a key; The performing random processing on the plurality of data segments based on the first sequence number of each data segment and the substitution table to obtain the second sequence number of each data segment includes: Obtaining a first sequence number of each data segment in the plurality of data segments and a number of data segments in the plurality of data segments, and comparing the number of data segments with the number of variables in the substitution table to generate a comparison result; determining a second sequence number for each of the plurality of data segments based on the substitution table, the first sequence number of each data segment, and the comparison result; The determining the second sequence number of each data segment based on the substitution table and the comparison result includes: If the comparison result indicates that the number of data segments is greater than the number of variables, and the first sequence number of the current data segment is greater than the number of variables, calculating a flag value corresponding to the current data segment using a preset flag value calculation method based on the first sequence number of the current data segment; Filter out a data segment to be adjusted whose number has the same flag value as that of the current data segment from the sorted data segments, and use the temporary sequence number of the data segment to be adjusted as the second sequence number of the current data segment; The sorted data segments are data segments with determined temporary sequence numbers among the multiple data segments.

2. The method according to claim 1, characterized in that Determining the second sequence number of each data segment in the plurality of data segments includes: Determine a target flag value that matches a first sequence number of a target data segment from the substitution table; the target data segment is: any data segment among the multiple data segments; A target sequence number corresponding to the target flag value is determined from the substitution table, and the target sequence number is determined as a second sequence number corresponding to the target data segment.

3. The method according to claim 1 or 2, characterized in that The determining, based on the substitution table and the comparison result, a second sequence number for each of the plurality of data segments, comprises: In a case where the comparison result indicates that the number of data segments is less than or equal to the number of variables, a second sequence number of each data segment is determined based on the substitution table.

4. The method according to claim 1 or 2, characterized in that The determining the second sequence number of each data segment based on the substitution table and the comparison result includes: When the comparison result indicates that the number of data segments is greater than the number of variables and the first sequence number of the current data segment is less than or equal to the number of variables, a temporary sequence number of the current data segment is determined based on the substitution table.

5. The method according to claim 1, wherein The determining the second sequence number of each data segment based on the substitution table and the comparison result includes: When there is no data segment with an undetermined temporary sequence number and no data segment with an undetermined second sequence number in the multiple data segments, the temporary sequence number corresponding to each data segment in the data segment with an undetermined second sequence number is determined as the second sequence number of each data segment.

6. The method according to claim 1, characterized in that The method for calculating the preset flag value includes: A value of a preset number of bits is intercepted from the key as an initial value of the memory unit; the number of bits stored in the memory unit is equal to the length of the long integer; Calculate a flag value corresponding to each data segment based on the state update of the memory unit; Among them, the state update of the memory unit includes: inputting the lower n bits of the memory unit into the substitution table to obtain the flag value corresponding to the current data segment; the state update of the memory unit also includes: inputting the flag value corresponding to the current data segment into the substitution table to obtain a first result value; performing an XOR operation on the first result value and the first sequence number corresponding to the current data segment to obtain a second result value; performing an XOR operation on the second result value and the memory unit to obtain a third result value; performing a shift operation on the third result value, cyclically shifting the third result value right by m bits to obtain a fourth result value; updating the state of the memory unit based on the fourth result value; n is the number of bits of the input data and output data of the substitution table, and m is a number that cannot be divided evenly by 64.

7. A data scrambling device, characterized in that: Applied in the field of data security, the device includes: a data processing module, configured to obtain a plurality of data segments to be sent, and determine a first sequence number for each data segment based on a natural ordering of each data segment among the plurality of data segments; a data shuffling module, configured to perform shuffling processing on the plurality of data segments based on the first sequence number of each data segment and a substitution table to obtain a second sequence number of each data segment, and after performing shuffling processing on the plurality of data segments based on the second sequence number of each data segment, send the plurality of data segments to a receiver; The permutation table is used to calculate the output sequence and the second sequence number of each data segment in the plurality of data segments; the permutation table is generated based on a key; The device further comprises: a comparison module; The data processing module is further configured to obtain a first sequence number of each data segment in the plurality of data segments and a number of data segments in the plurality of data segments; The comparison module is used to compare the number of data segments with the number of variables in the substitution table to generate a comparison result; The data shuffling module is specifically configured to determine a second sequence number for each of the plurality of data segments based on the substitution table, the first sequence number of each data segment, and the comparison result; The data shuffling module is specifically configured to calculate a flag value corresponding to the current data segment using a preset flag value calculation method based on the first sequence number of the current data segment when the comparison result indicates that the number of data segments is greater than the number of variables and the first sequence number of the current data segment is greater than the number of variables; The data shuffling module is further configured to filter out, from the sorted data segments, a data segment with a to-be-adjusted number and a flag value identical to that corresponding to the current data segment, and use the temporary sequence number of the data segment with the to-be-adjusted number as the second sequence number of the current data segment; The sorted data segments are data segments with determined temporary sequence numbers among the multiple data segments.

8. The device according to claim 7, characterized in that The data shuffling module is specifically configured to determine a target flag value that matches a first sequence number of a target data segment from the substitution table; the target data segment is any one of the multiple data segments; The data disorder module is further configured to determine a target sequence number corresponding to the target flag value from the replacement table, and determine the target sequence number as a second sequence number corresponding to the target data segment.

9. The device according to claim 7 or 8, characterized in that The data shuffling module is specifically configured to determine a second sequence number for each data segment based on the substitution table when the comparison result indicates that the number of data segments is less than or equal to the number of variables.

10. The device according to claim 7 or 8, characterized in that The data disorder module is specifically used to determine the temporary sequence number of the current data segment based on the substitution table when the comparison result indicates that the number of data segments is greater than the number of variables and the first sequence number of the current data segment is less than or equal to the number of variables.

11. The device according to claim 7, characterized in that The data disorder module is specifically used to determine the temporary sequence number corresponding to each data segment in the data segments with undetermined second sequence numbers as the second sequence number of each data segment when there is no data segment with undetermined temporary sequence numbers and no data segment with undetermined second sequence numbers in the multiple data segments.

12. The device according to claim 7, characterized in that The device further comprises: a generating module; The generating module is used to intercept a value of a preset number of bits from the key as an initial value of the memory unit; the number of bits stored in the memory unit is equal to the length of the long integer; The generating module is further configured to calculate a flag value corresponding to each data segment based on a status update of the memory unit; Among them, the state update of the memory unit includes: inputting the lower n bits of the memory unit into the substitution table to obtain the flag value corresponding to the current data segment; the state update of the memory unit also includes: inputting the flag value corresponding to the current data segment into the substitution table to obtain a first result value; performing an XOR operation on the first result value and the first sequence number corresponding to the current data segment to obtain a second result value; performing an XOR operation on the second result value and the memory unit to obtain a third result value; performing a shift operation on the third result value, cyclically shifting the third result value right by m bits to obtain a fourth result value; updating the memory unit based on the fourth result value; n is the number of bits of the input data and output data of the substitution table, and m is a number that cannot be divided evenly by 64.

13. An electronic device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the data scrambling method according to any one of claims 1 to 6 when executing the program.

14. A computer-readable storage medium, characterized in that A computer program is stored thereon, and when the computer program is executed by a processor, the steps of the data scrambling method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • File encryption method and device

    CN118211245A