A method for encrypting and decrypting images in the spatial domain
Through the improved Logistic chaotic mapping and Warnsdorff rule to confuse the quadratic prediction feedback method, the problem of limited parameter range and uneven distribution of chaotic sequences is solved, and a more efficient and secure image encryption effect is achieved.
Patent Information
- Application Number
- CN202210882754.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-26
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2042-07-26
AI Technical Summary
Classic Logistic chaotic mapping has problems such as limited system parameter range and uneven distribution of chaotic sequences, resulting in unsatisfactory encryption effects.
The image space encryption method using the improved Logistic chaotic mapping and Warnsdorff rule to quadratic prediction feedback is adopted. By extending the generation parameters of the Logistic chaotic mapping, the pseudo-randomness of the chaotic sequence is enhanced, and the Warnsdorff rule to generate the chaotic sequence is used to stream the image data.
The generation parameters of Logistic chaotic mapping are effectively expanded, the confidentiality and pseudo-randomness of chaotic sequences are enhanced, and the chaotic sequence is generated through the quadratic prediction feedback algorithm, which significantly improves the security and efficiency of image encryption.
Smart Images

Figure CN115208551B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to an improved encryption method based on Logistic chaotic mapping for image spatial domain encryption, and particularly to an image spatial domain encryption method based on improved Logistic chaotic mapping and Warnsdorff rule scrambling with secondary prediction feedback. Background Art
[0002] Digital images are a widely adopted data format. Due to characteristics such as being fast and convenient, and having a large amount of information, they have extensive applications in various fields. With the wide application of digital images, especially the transmission of image data in a network environment, the security protection of digital images has become increasingly important. The most direct method for image security protection is to encrypt the image data.
[0003] The development of Internet technology has provided us with a channel for cross-regional data transmission. Especially in recent years, the development of 4G / 5G technology has made it possible for image and video data to be freely transmitted over the network. Since image or video data is easily intercepted illegally when transmitted in the network, especially in a wireless network, people have put forward very high requirements for the security of multimedia data transmission such as images and videos. The most direct method to ensure secure data transmission is to encrypt the data. Therefore, encryption algorithms for media such as images and videos have emerged and have developed rapidly in recent years.
[0004] Chaotic systems have advantages such as sensitivity to initial conditions, ergodicity, and mixing properties, which meet the requirements of cryptography. Therefore, in recent years, digital image spatial domain encryption schemes based on chaotic theory have achieved rapid development. Image encryption algorithms based on knight's tour scrambling have received extensive attention and research in the academic community in recent years due to characteristics such as a large key space, resistance to exhaustive attacks, and strong key sensitivity.
[0005] I. Logistic Chaotic Mapping
[0006] Chaos originates from nonlinear dynamic systems and is an arbitrary time-varying process. This process is deterministic, pseudo-random, non-periodic, and has an extremely sensitive dependence on the initial value. These characteristics exactly meet the requirements of stream ciphers, so chaos is often used in the data encryption process. The Logistic map is a classic model for studying the behavior of complex systems such as dynamic systems, chaos, and fractals. Due to its simple principle and convenient calculation, it is widely used in the encryption field. The mathematical expression of one-dimensional Logistic mapping is described as:
[0007]
[0008] In the above formula, μ ∈ (0, 4] is called the Logistic parameter. When X ∈ (0, 1), the Logistic map is in a chaotic state. That is to say, the initial condition X 0 ∈ (0, 1) generates a non-periodic and non-convergent sequence under the iteration of the Logistic map. And when X 0 or the parameter μ changes slightly, the sequences generated under the iteration of the Logistic map are very different.
[0009] II. Data Encryption Based on the Logistic Chaotic Map
[0010] Set the initial parameters μ and X 0 , calculate the chaotic set X = {x0, x1, x2, …, xn-1} obtained by the iteration of the Logistic map, where x i ∈ (0, 1). Perform operations on X: , to obtain the set H = {h0, h1, h2, …, hn-1}. For the data stream D = {d0, d1, d2, …, dn-1}, perform the exclusive OR operation with H , to obtain the ciphertext E = {e0, e1, e2, …, en-1} of the data stream D. Perform the exclusive OR operation on the ciphertext E with H again , to obtain the original data stream D. Here we call the initial parameters μ and X 0 the key. Based on the chaotic sequence generated by the iteration of the Logistic map, symmetric encryption of the data stream is realized.
[0011] However, the classical Logistic map has problems such as limited system parameter range and uneven distribution of chaotic sequences.
[0012] III. The Knight's Tour Problem and Warnsdorff's Rule
[0013] The knight's tour problem is a classic problem in graph theory. The chessboard of chess is an m×n square chessboard. Now place the knight (horse) in any designated square and move it according to the rules of the knight's move (similar to Chinese chess, the horse moves in an L-shape). It is required that each square can only be entered once, and finally the knight can visit each square of the chessboard. This is the knight's tour problem. For an m×n square chessboard, when the knight visits each square of the chessboard, its tour path is disordered. We can reorder the pixels or spatial sub-blocks of the image to be encrypted according to the knight's tour order, so as to achieve the purpose of hiding the image information and achieve the encryption effect. We usually call this the scrambling of the image. At present, the image encryption algorithm based on knight's tour scrambling has received extensive attention and research in the academic community in recent years due to its large key space, ability to resist exhaustive attacks, and strong key sensitivity.
[0014] Generally, since the starting position of the knight on the chessboard is arbitrary, under the restrictions of the movement rules, it is very difficult to traverse every square of the chessboard if moving randomly according to the rules. The most classic algorithm for solving the knight's tour problem was invented by the German mathematician H.C. Warnsdorff in 1823, called the Warnsdorff's rule. The main idea of the Warnsdorff's rule is that when moving from the starting position, one should not rashly move the knight to a certain candidate position, but instead predict and judge all the candidate positions to find the optimal candidate position for movement. The Warnsdorff's rule believes that the optimal candidate position is the point with the fewest candidate positions for the next move among all the candidate positions as the starting point for the next move. This method is what we call predictive feedback, as Figure 1 shown.
[0015] Figure 1 Shown is the situation of the 10th step of the knight's tour: Starting from the current position of the knight (the position where the horse character is located), there are three possible positions to move to, namely the squares where ②, ⑤, and ⑥ are located. The numbers shown in the squares are the number of candidate positions for the next move when this square is used as the starting position. At this time, we choose the one with the fewest candidate positions for the next move as the optimal candidate position. Obviously, the tenth step should jump to the position where ② is located. The Warnsdorff algorithm is not effective for all situations. When the chessboard is larger than 76×76, this algorithm becomes invalid. Summary of the Invention
[0016] To solve the problems that the classic Logistic map has restricted system parameter range and uneven distribution of chaotic sequences, the present invention provides an image spatial domain encryption method based on an improved Logistic chaotic map and the Warnsdorff's rule scrambling quadratic predictive feedback.
[0017] The technical solution of the present invention:
[0018] A method for image spatial domain encryption and decryption, the image encryption method comprising the following steps:
[0019] (1) Establish a Logistic chaotic sequence Z = {z 0 , z 1 , …, z n-1};
[0020] (2) Use the quadratic predictive feedback algorithm of the Warnsdorff's rule to traverse a 16×16 chessboard, starting from the chessboard position, obtain the traversal path and convert it into a one-dimensional array;
[0021] (3) Encrypt the image data;
[0022] (4) Image data ciphertext scrambling.
[0023] Preferably, the image decryption method includes the following steps:
[0024] (1) Establish a Logistic chaotic sequence Z = {z 0 , z 1 , …, z n-1};
[0025] (2) Use the quadratic prediction feedback algorithm of Warnsdorff's rule to traverse a 16×16 chessboard, starting from the chessboard position, obtain the traversal path and convert it into a one-dimensional array;
[0026] (3) Image data reverse scrambling;
[0027] (4) Image data decryption.
[0028] Preferably, in the steps of the image encryption method, before the step of establishing the Logistic chaotic sequence Z = {z 0 , z 1 , …, z n-1}, the following steps are also included:
[0029] Convert the image pixels into a one-dimensional array form according to the row sequence, and each pixel R, G, B component is used as an element of the one-dimensional array; assume there is an image D = m×l, where m is the height and l is the width of the image. According to the above principle, the image D can be expressed as {R 0 , G 0 , B 0 , R 1 , G 1 , B 1 , ……, R m×l-1 , G m×l-1 , B m×l-1}, for the convenience of calculation, here let D = {d 0 ,d 1 , …, d k-1}, where k is 3 times the number of image pixels, k = m×l×3.
[0030] Preferably, the Logistic chaotic sequence Z includes the following steps:
[0031] (a) Set parameters x 0 , μ, delay, cycle, multipower, bitswap;
[0032] (b) According to x n = x n-1*μ*(1 - x n-1 ), perform chaotic sequence iterative calculation;
[0033] (c) After delay iterations, take the stable chaotic sequence with sequence length cycle to obtain the chaotic sequence X = {x 0 , x 1 , …, x n-1}, n = cycle;
[0034] (d) For the obtained chaotic sequence X, calculate (X * multipower) % 256 to obtain the byte chaotic sequence H = {h 0 , h 1 , …, h n-1};
[0035] (e) For each element h i in the H sequence, perform a shift operation. According to the value of i % 3, perform a 1827, 1234, or 1526 - bit swap operation; if i % 3 == 0, perform a 1827 - bit swap operation on hi; if i % 3 == 1, perform a 1234 - bit swap operation on hi; if i % 3 == 2, perform a 1526 - bit swap operation on hi;
[0036] (f) According to bitswap, perform a shift operation on each element h i in the H sequence again. If bitswap == 0, perform a 1827 - bit swap operation on h i ; if bitswap == 1, perform a 1234 - bit swap operation on h i ; if bitswap == 2, perform a 1526 - bit swap operation on h i .
[0037] Preferably, in step (2), traverse the 16×16 chessboard, starting from the chessboard positions (0, 0), (7, 7), (15, 15), obtain the traversal path and convert it into a one - dimensional array, denoted as W00
[256] , W77
[256] , W1515
[256] ;
[0038] The secondary prediction feedback algorithm of Warnsdorff's rule:
[0039] Adopt the secondary prediction feedback algorithm. That is, when the number of candidate positions for the next move obtained after one prediction is the same, start the secondary prediction. The prediction method is the same as the one - time prediction: starting from multiple least - candidate - position points, perform a re - move prediction, add up the number of candidate positions for the secondary move prediction to obtain the sum of the secondary - prediction candidate positions; select the one - time - prediction least - candidate - position point with the smallest sum of secondary - prediction candidate positions as the moving point.
[0040] Preferably, the image data row encryption step includes:
[0041] For the image data sequence D = {d 0 , d 1 , …, d k-1} to be encrypted, perform an exclusive OR operation on the corresponding elements according to the sequence numbers of the data sequence and the chaotic sequence to implement the encryption of the image data, and obtain the ciphertext E = {e , e 0 , …, e 1 ,…, e k-1} of the data sequence, that is That is, e i = d i z i%n , where i = 0, 1, …, k - 1;
[0042] For the image data ciphertext sequence E = {e 0 , e 1 , …, e k-1}, group it according to every 256 elements to obtain k / 256 E groups, denoted as E t , t = 0, 1, …, k / 256 - 1; when t % 3 = 0, perform scrambling using W00
[256] , when t % 3 = 1, perform scrambling using W77
[256] , and when t % 3 = 2, perform scrambling using W1515
[256] ;
[0043] The obtained E-Scrambling is the final encrypted sequence of the image data.
[0044] Preferably, the image data descrambling step includes:
[0045] For the image data ciphertext scrambled sequence E-Scrambling, group it according to every 256 elements to obtain k / 256 E-Scrambling groups, denoted as E-S t , t = 0, 1, …, k / 256 - 1; when t % 3 = 0, perform descrambling using W00
[256] , when t % 3 = 1, perform descrambling using W77
[256] , and when t % 3 = 2, perform descrambling using W1515
[256] ;
[0046] After performing the descrambling operation, obtain the encrypted sequence E of the image data;
[0047] The image data decryption step includes:
[0048] For the encrypted image data sequence E = {e 0 , e 1 , …, ek-1}, perform XOR operation on the corresponding elements according to the sequence numbers of the data sequence and the chaotic sequence to decrypt the data and obtain the plaintext D = {d 0 , d 1 , …, d k-1} of the data sequence, that is that is, d i = e i z i%n , i = 0, 1, …, k - 1.
[0049] Preferably, convert the knight's tour sequence generated by the quadratic prediction feedback algorithm based on Warnsdorff's rule into a one-dimensional array form, denoted as W[16×16] = {w 0 , w 1 , ……, w 254 , w 255}, and use W[16×16] to scramble and unscramble the image D = {d 0 , d 1 , …, d k-1};
[0050] Scrambling algorithm: D-Scrambling[i] = D[(i / 256)*256 + W[i%256]], i = 0, 1, …, k - 1;
[0051] The scrambling algorithm for each group is as follows: E t -Scrambling[i] = E t [W[i]], t = 0, 1, …, k / 256 - 1; i = 0, 1, …, 255;
[0052] Unscrambling algorithm: D[(i / 256)*256 + W[i%256]] = D-Scrambling[i], i = 0, 1, …, k - 1;
[0053] The unscrambling algorithm for each group is as follows: E t [W[i]] = E-S t [i], t = 0, 1, …, k / 256 - 1; i = 0, 1, …, 255.
[0054] Preferably, x 0: Initial value, with a value range of (0, 1); μ: Logistic parameter, with a value range of (0, 4]; delay: Delay, the number of iterations for the chaotic sequence to stabilize; cycle: Period, referring to the length of the obtained chaotic sequence; multipower: Multiplier, the multiplier when calculating the byte chaotic series from the decimal chaotic sequence; bitswap: Bit swap algorithm, providing three swap algorithms: 1827 swap algorithm, 1234 swap algorithm, 1526 swap algorithm.
[0055] Preferably, x 0 takes the value of 0.5438125; μ: takes the value of 3.9438125; delay: takes the value of 100; cycle: takes the value of 256; multipower: takes the value of 10 6 ;
[0056] 1827 swap algorithm: Swap the first and eighth bits, the second and seventh bits, the third and sixth bits, and the fourth and fifth bits of the byte to generate a new byte;
[0057] 1234 swap algorithm: Swap the first and second bits, the third and fourth bits, the fifth and sixth bits, and the seventh and eighth bits of the byte to generate a new byte;
[0058] 1526 swap algorithm: Swap the first and fifth bits, the second and sixth bits, the third and seventh bits, and the fourth and eighth bits of the byte to generate a new byte.
[0059] Advantages of the present invention:
[0060] This method expands the generation parameters of the Logistic chaotic map and further performs bit swapping on the generated chaotic sequence, enhancing its pseudo-randomness. This method generates a 16×16 block scrambling sequence through the Warnsdorff rule of quadratic prediction feedback and performs streaming scrambling on the image data. Based on the generated Logistic chaotic sequence and Warnsdorff 16×16 block scrambling sequence, this method proposes a complete image encryption algorithm. Specifically, it is manifested in the following aspects:
[0061] 1. Use the chaotic map to derive a discrete chaotic encryption sequence, perform amplification modulo operation on it, and then perform bit swapping operation to enhance its pseudo-randomness.
[0062] 2. Expand the initial parameters to enhance the confidentiality of the generated chaotic sequence.
[0063] 3. Adopt a quadratic prediction feedback algorithm based on the Warnsdorff rule to generate three scrambling sequences, respectively scramble the ciphertext, and enhance the confidentiality of the scrambling.
[0064] 4. Continuously scramble the digital image to eliminate the block effect as much as possible. Description of the Drawings
[0065] Figure 1 It is a diagram of the 10th step of the knight's tour;
[0066] Figure 2 It is a diagram of the 1827-bit swap algorithm;
[0067] Figure 3 It is a diagram of the 1234-bit swap algorithm;
[0068] Figure 4 It is a diagram of the 1526-bit swap algorithm;
[0069] Figure 5 It is a diagram of selecting the 1.2 points with the fewest number of movement candidate points for the next step as the target point of this movement;
[0070] Figure 6 It is a diagram of the number of candidate points for the next step obtained by making a prediction for each movement candidate point;
[0071] Figure 7 For Prediction diagram;
[0072] Figure 8 For Prediction diagram;
[0073] Figure 9 For Prediction diagram;
[0074] Figure 10 It is a diagram of selecting the point with the sum of the secondary prediction candidate points being 9 as the target point of this movement;
[0075] Figure 11 It is a diagram of the knight's tour path with the initial position at (0, 0);
[0076] Figure 12 It is a diagram of the knight's tour path with the initial position at (7, 7);
[0077] Figure 13 It is a diagram of the knight's tour path with the initial position at (15, 15). Detailed Implementation Manner
[0078] I. Logistic Chaos Sequence Generation Parameters
[0079] Generate a chaos sequence based on the Logistic chaos mapping, and the initial parameters are set as:
[0080] x 0: Initial value, with a value range of (0, 1), and taking the value (not limited to) 0.5438125 here.
[0081] μ: Logistic parameter, with a value range of (0, 4], and taking the value (not limited to) 3.9438125 here.
[0082] delay: Delay, the number of iterations waited for the chaotic sequence to stabilize, and taking the value (not limited to) 100 here.
[0083] cycle: Period, referring to the length of the obtained chaotic sequence, and taking the value (not limited to) 256 here.
[0084] multipower: Multiplier, taking the value (not limited to) 10 6 , which is the multiplier when calculating the byte chaotic series from the decimal chaotic sequence.
[0085] bitswap: Bit swapping algorithm, providing three swapping algorithms: 1827 swapping algorithm, 1234 swapping algorithm, 1526 swapping algorithm.
[0086] II. Bit Swapping Algorithm
[0087] Three bit swapping algorithms are provided to perform bit swapping operations on each element of the chaotic series to be selected.
[0088] 1. 1827 Bit Swapping Algorithm (see Figure 2 )
[0089] Swap the first and eighth bits, the second and seventh bits, the third and sixth bits, and the fourth and fifth bits of the byte to generate a new byte.
[0090] 2. 1234 Bit Swapping Algorithm (see Figure 3 )
[0091] Swap the first and second bits, the third and fourth bits, the fifth and sixth bits, and the seventh and eighth bits of the byte to generate a new byte.
[0092] 3. 1526 Bit Swapping Algorithm (see Figure 4 )
[0093] Swap the first and fifth bits, the second and sixth bits, the third and seventh bits, and the fourth and eighth bits of the byte to generate a new byte.
[0094] III. Generation Process of Logistic Chaotic Sequence
[0095] 1. Set parameters x 0 , μ, delay, cycle, multipower, bitswap
[0096] 2. According to x n = x n-1 * μ * (1 - x n-1 ), perform chaotic sequence iterative calculation, and use x 0 as the initial value for iterative calculation;
[0097] 3. After delay iterations, take the stable chaotic sequence with a sequence length of cycle to obtain the chaotic sequence X = {x 0 , x 1 , …, x n-1}, n = cycle.
[0098] 4. For the obtained chaotic sequence X, calculate (X * multipower) % 256 to obtain the byte chaotic sequence H = {h 0 , h 1 , …, h n-1}; h 0= (x 0 * multipower) % 256, h n-1 = (x n-1 * multipower) % 256;
[0099] 5. Perform a shift operation on each element h i of the H sequence, and perform a 1827, 1234, or 1526-bit swap operation according to the value of i % 3. If i % 3 == 0, perform a 1827-bit swap operation on h i ; if i % 3 == 1, perform a 1234-bit swap operation on h i ; if i % 3 == 2, perform a 1526-bit swap operation on h i .
[0100] 6. According to bitswap, perform a shift operation on each element h i of the H sequence again. If bitswap == 0, perform a 1827-bit swap operation on h i ; if bitswap == 1, perform a 1234-bit swap operation on h i ; if bitswap == 2, perform a 1526-bit swap operation on h i .
[0101] 7. Obtain the final Logistic chaotic sequence Z = {z 0 , z 1 , …, z n-1}.
[0102] IV. Encryption and Decryption Process of Image Data Using the Generated Logistic Chaotic Sequence
[0103] 1. One-dimensionalization of image data:
[0104] Convert the image pixels into a one-dimensional array form according to the row sequence, and each pixel's R, G, and B components serve as an element of the one-dimensional array. Given an image D(m×l), where m is the height and l is the width of the image. According to the above principle, the image D can be represented as {R 0 , G 0 , B 0 , R 1 , G 1 , B 1 , ……, R m×l-1 , G m×l-1 , B m×l-1}
[0105] 2. Encryption process:
[0106] For convenience of calculation, represent D = {R 0 , G 0 , B 0 , R 1 , G 1 , B 1 , ……, R m×l-1 , G m×l-1 , B m×l-1} as D = {d 0 , d 1 , …, d k-1}, where k = m×l×3.
[0107] For the image data sequence D = {d 0 , d 1 , …, d k-1}, perform the exclusive OR operation on the corresponding elements according to the sequence numbers of the data sequence and the chaotic sequence to encrypt the image data, and obtain the ciphertext E = {e 0 , e 1 ,…, e k-1} of the data sequence, that is That is, e i = d i z i%n , where i = 0, …, k - 1.
[0108] 3. Decryption process:
[0109] For the ciphertext E = {e 0 , e 1 , …, e k-1 }, perform exclusive OR on the corresponding elements according to the sequence numbers of the data sequence and the chaotic sequence operation to decrypt the image data and obtain the original text D = {d 0 , d 1 , …, d k-1} of the data sequence, that is, E Z = D, that is, d i = e i z i%n , where i = 0, …, k - 1.
[0110] V. Quadratic Prediction Feedback Algorithm of Warnsdorff's Rule
[0111] The main idea of Warnsdorff's rule is that when moving from the starting position, the knight cannot be rashly moved to a certain candidate position. Instead, all candidate positions need to be predicted and judged to find the optimal candidate position for movement. Warnsdorff's rule believes that the optimal candidate position is the point with the fewest candidate positions for the next move starting from all candidate positions, that is, the optimal candidate position point. This method is called prediction feedback. In actual operation, the number of candidate positions for the next move obtained through one prediction may be more than one. Generally, the processing method at this time is to choose one arbitrarily, or choose the point farthest from the center position of the chessboard, but this choice is uncertain and may lead to the failure of the tour traversal. The present invention adopts a quadratic prediction feedback algorithm, that is, when the number of candidate positions for the next move obtained through one prediction is the same, start the quadratic prediction, and the prediction method is the same as that of the one-time prediction: starting from multiple points with the fewest candidate positions, perform another movement prediction, and add up the number of candidate positions for the quadratic movement prediction to obtain the sum of the candidate positions for the quadratic prediction. At this time, select the one-time prediction with the fewest candidate positions whose sum of the candidate positions for the quadratic prediction is the smallest as the movement point. The process is as follows.
[0112] Figure 5 In, the number of candidate positions for the next move of each movement candidate point in the one-time prediction is different. Select the 1.2 points with the fewest candidate positions for the next move as the target point for this movement. Figure 5 For the numbers 1.2, 1.7, etc. in, the first number represents the number of predictions, and the second number represents the number of candidate positions in the one-time prediction.
[0113] However, as Figure 6 shown, the black dots on the chessboard represent the occupied points. At this time, the number of candidate positions for the next move obtained by performing one prediction on each movement candidate point is the same for some. Figure 6There are three positions where the number of candidate points for the next move is 2, and 2 is the minimum value of the number of candidate points for the next move. At this time, one prediction fails and a second prediction is required.
[0114] For the prediction is as Figure 7 shown. In the figure, 1.2.2 and 1.2.7 represent two candidate move points for 1.2. The last digits 2 and 7 represent the number of candidate move points for the second prediction. There are two candidate move points. The number of candidate points for the next move of the two candidate move points for the second prediction are 2 and 7 respectively, and their sum is 9.
[0115] For the prediction is as Figure 8 shown. This point has two candidate move points. The number of candidate points for the next move of the two candidate move points for the second prediction are 5 and 7 respectively, and their sum is 12.
[0116] For the prediction is as Figure 9 shown. This point has two candidate move points. The number of candidate points for the next move of the two candidate move points for the second prediction are 3 and 7 respectively, and their sum is 10.
[0117] At this time, since the sums of the candidate points for the second prediction of the three points with the smallest and same number of candidate points for the first prediction are 9, 12, and 10 respectively, the point with the sum of the candidate points for the second prediction of 9 is selected as the target point for this move. See Figure 10 .
[0118] Set the 16×16 chessboard and the initial position of the knight, and use the second prediction feedback algorithm of Warnsdorff's rule to traverse the chessboard, and record the number of moves at the chessboard grid positions.
[0119] Figure 11 is the knight's traversal path with the initial position in the upper left corner, that is, the (0, 0) position.
[0120] Figure 12 is the knight's traversal path with the initial position in the lower right corner, that is, the (7, 7) position.
[0121] Figure 13 is the knight's traversal path with the initial position in the (15, 15) position.
[0122] VI. Method for Row Scrambling of Image Data by Knight's Tour Sequence
[0123] Convert the knight's tour sequence generated by the second prediction feedback algorithm based on Warnsdorff's rule into a one-dimensional array form, denoted as W[16×16]={w 0 , w 1, ……, w 254 , w 255}, use W[16×16] to scramble and descramble the image D = {d 0 , d 1 , …, d k-1}.
[0124] 1. Scrambling algorithm
[0125] D-Scrambling[i] = D[(i / 256)*256+W[i%256]], i = 0, 1, …, k-1.
[0126] 2. Descrambling algorithm
[0127] D[(i / 256)*256+W[i%256]] = D-Scrambling[i], i = 0, 1, …, k-1.
[0128] VII. Image spatial domain encryption steps of the present invention
[0129] 1. Convert the image pixels into a one-dimensional array form according to the row sequence, and each pixel R, G, B component is used as an element of the one-dimensional array. Given an image D (m×l), where m is the height and l is the width of the image. According to the above principle, the image D can be expressed as {R 0 , G 0 , B 0 , R 1 , G 1 , B 1 , ……, R m×l-1 , G m×l-1 , B m×l-1}. For the convenience of calculation, here let D = {d0, d1, …, dk-1}, where k is 3 times the number of image pixels, k = m×l×3.
[0130] 2. Set parameters x 0 , μ, delay, cycle, multipower, bitswap
[0131] 3. According to x n =x n-1 *μ*(1-x n-1 ), perform chaotic sequence iterative calculation.
[0132] 4. After delay iterations, take the stable chaotic sequence with a sequence length of cycle to obtain the chaotic sequence X = {x 0 , x 1 , …, x n-1}, n = cycle.
[0133] 5. For the obtained chaotic sequence X, calculate (X* multipower)%256 to obtain the byte chaotic sequence H={h 0 ,h 1 , …, h n-1}.
[0134] 6. Element by element h of the H sequence i Perform a shift operation, and perform a 1827, 1234, or 1526-bit swap operation according to the value of element number i%3. If i%3==0, perform a 1827-bit swap operation on hi; if i%3==1, perform a 1234-bit swap operation on hi; if i%3==2, perform a 1526-bit swap operation on hi.
[0135] 7. According to bitswap, h is performed on each element of the H sequence. i Perform the shift operation again. If bitswap==0, then h i Perform a 1827 bit swap operation; if bitswap==1, then h i Perform a 1234 bit swap operation; if bitswap==2, then h i Perform a 1526-bit swap operation.
[0136] 8. Get the final Logistic chaotic sequence Z = {z 0 , z 1 , …, z n-1}.
[0137] 9. Use the quadratic predictive feedback algorithm of the Warnsdorff rule to traverse the 16×16 chessboard, starting from the chessboard positions (0, 0), (7, 7), and (15, 15). The traversal path is obtained and converted into a one-dimensional array, recorded as W00
[256] , W77
[256] , and W1515
[256] .
[0138] 9. Image data row encryption.
[0139] For the image data sequence to be encrypted D={d 0 , d 1 , …, d k-1}, perform XOR of corresponding elements according to the sequence numbers of the data sequence and the chaotic sequence ( ) operation to encrypt the image data and obtain the ciphertext E={e 0 , e 1 ,…, e k-1}, that is, D Z=E, that is, e i =d i z i%n , where \(i = 0, 1, \ldots, k - 1\).
[0140] 10. Image data ciphertext scrambling.
[0141] For the image data ciphertext sequence \(E=\{e 0 , e 1 , \ldots, e k-1 \}\), group it by every 256 elements to get \(k / 256\) groups of \(E\), denoted as \(E t \), where \(t = 0, 1, \ldots, k / 256 - 1\). When \(t\%3 = 0\), use \(W00
[256] \) for scrambling; when \(t\%3 = 1\), use \(W77
[256] \) for scrambling; when \(t\%3 = 2\), use \(W1515
[256] \) for scrambling.
[0142] The scrambling algorithm for each group is as follows:
[0143] E t -Scrambling[i]=E t [W[i]], where \(t = 0, 1, \ldots, k / 256 - 1\); \(i = 0, 1, \ldots, 255\);
[0144] The obtained \(E - Scrambling\) is the final encrypted sequence of the image data.
[0145] VIII. Image spatial domain decryption steps of the present invention
[0146] 1. Set parameters \(x 0 \), \(\mu\), \(delay\), \(cycle\), \(multipower\), \(bitswap\), the same as in the encryption algorithm.
[0147] 2. According to \(x n =x n-1 *\(\mu\)*(1 - x n-1 ), perform chaotic sequence iterative calculation.
[0148] 3. After \(delay\) iterations, take the stable chaotic sequence with a sequence length of \(cycle\) to obtain the chaotic sequence \(X=\{x 0 , x 1 , \ldots, x n-1 \}\), \(n = cycle\).
[0149] 4. For the obtained chaotic sequence \(X\), calculate \((X * multipower)\%256\) to obtain the byte chaotic sequence \(H=\{h 0 ,h 1 , \ldots, h n-1 \}\).
[0150] 5. Perform an h shift operation on each element of the H sequence. According to the value of i%3, perform a bit swap operation of 1827, 1234, or 1526 bits. If i%3 == 0, perform a 1827-bit swap operation on hi; if i%3 == 1, perform a 1234-bit swap operation on hi; if i%3 == 2, perform a 1526-bit swap operation on hi. i 6. According to bitswap, perform a shift operation on each element h of the H sequence again. If bitswap == 0, perform a 1827-bit swap operation on h; if bitswap == 1, perform a 1234-bit swap operation on h; if bitswap == 2, perform a 1526-bit swap operation on h.
[0151] 7. Obtain the final Logistic chaotic sequence Z = {z i , z i , …, z i}. i 8. Use the quadratic prediction feedback algorithm of the Warnsdorff rule to traverse the 16×16 chessboard. Starting from the chessboard positions (0, 0), (7, 7), (15, 15), obtain the traversal path and convert it into a one-dimensional array, denoted as W00
[256] , W77
[256] , W1515
[256] .
[0152] 9. Inverse scrambling of image data. 0 1 n-1
[0153] For the encrypted scrambling sequence E-Scrambling of image data, group it according to every 256 elements to obtain k / 256 E-Scrambling groups, denoted as E-S
[0154] , t = 0, 1, …, k / 256 - 1. When t%3 = 0, perform inverse scrambling using W00
[256] ; when t%3 = 1, perform inverse scrambling using W77
[256] ; when t%3 = 2, perform inverse scrambling using W1515
[256] .
[0155] The inverse scrambling algorithm for each group is as follows:
[0156] E t [W[i]] = E-S
[0157] [i], t = 0, 1, …, k / 256 - 1; i = 0, 1, …, 255;
[0158] After performing the inverse scrambling operation, obtain the encrypted sequence E of the image data. t t
[0159] 10. Image data decryption.
[0160] For the encrypted image data sequence E = {e 0 , e 1 , …, e k-1}, perform the exclusive OR ( ) operation on the corresponding elements according to the serial numbers of the data sequence and the chaotic sequence to decrypt the data and obtain the plaintext D = {d 0 , d 1 , …, d k-1} of the data sequence, that is, E Z = D, that is, d i = e i z i%n , i = 0, 1, …, k - 1.
[0161] The above are only the preferred embodiments of the present invention, and do not impose any form of limitation on the present invention. Although the present invention has been disclosed as above with the preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art can make some changes or modifications to the equivalent embodiments with equivalent changes within the scope of the technical solution of the present invention. However, as long as it does not depart from the content of the technical solution of the present invention, any brief modifications, equivalent changes and modifications made to the above embodiments based on the technical essence of the present invention still fall within the scope of the technical solution of the present invention.
Claims
1. A method for image spatial domain encryption and decryption, characterized in that, the image encryption method comprises the following steps: (1) Establish the Logistic chaotic sequence Z = {z 0 , z 1 , …, z n-1}; (2) Traverse a 16×16 chessboard using the quadratic prediction feedback algorithm of the Warnsdorff rule, starting from the chessboard position, obtain the traversal path and convert it into a one-dimensional array; (3) Encrypt the image data; (4) Scramble the ciphertext of the image data; In step (2), traverse the 16×16 chessboard, starting from the chessboard positions (0, 0), (7, 7), (15, 15), obtain the traversal path and convert it into a one-dimensional array, denoted as W00[256], W77[256], W1515[256]; The quadratic prediction feedback algorithm of the Warnsdorff rule: Adopt the quadratic prediction feedback algorithm, that is, when the number of candidate positions for the next move obtained by one prediction is the same, start the quadratic prediction, and the prediction method is the same as that of the one prediction: starting from multiple least candidate position points, perform another move prediction, add up the number of candidate positions for the quadratic move prediction to obtain the sum of the candidate positions for the quadratic prediction; select the least candidate position point of the one prediction with the smallest sum of the candidate positions for the quadratic prediction as the moving point; The image decryption method comprises the following steps: (1) Establish the Logistic chaotic sequence \(Z = \{z 0 , z 1 , \ldots, z n-1 \}\); (2) Traverse a 16×16 chessboard using the quadratic prediction feedback algorithm of the Warnsdorff rule, starting from the chessboard position, obtain the traversal path and convert it into a one-dimensional array; (3) Unscramble the image data; (4) Decrypt the image data.
2. A method for image spatial domain encryption and decryption according to claim 1, characterized in that, In the steps of the image encryption method, before the step of establishing a Logistic chaotic sequence Z = {z 0 , z 1 , …, z n-1}, the following steps are further included: Convert the image pixels into a one-dimensional array form according to the row sequence, and each pixel's R, G, and B components serve as an element of the one-dimensional array. Given an image D = m×l, where m is the height and l is the width of the image. According to the above principle, the image D can be represented as {R 0 , G 0 , B 0 , R 1 , G 1 , B 1 , ……, R m×l-1 , G m×l-1 , B m×l-1}. For the convenience of calculation, here let D = {d 0 , d 1 , …, d k-1}, where k is three times the number of image pixels, and k = m×l×3.
3. A method for image spatial domain encryption and decryption according to claim 1, characterized in that, The Logistic chaotic sequence Z comprises the following steps: (a) Set parameter x 0 , μ, delay, cycle, multipower, bitswap; (b), according to x n = x n-1 *μ*(1 - x n-1 ), perform chaotic sequence iterative calculation; (c) After delay iterations, take the stable chaotic sequence with a sequence length of cycle to obtain the chaotic sequence X = {x 0 , x 1 , …, x n-1}, where n = cycle; (d), for the obtained chaotic sequence X, calculate (X * multipower) % 256 to obtain the byte chaotic sequence H = {h 0 , h 1 , …, h n-1}; (e), perform an element-by-element shift operation on the H sequence h i and perform a 1827-, 1234-, or 1526-bit swap operation according to the value of i % 3; if i % 3 == 0, perform a 1827-bit swap operation on hi; if i % 3 == 1, perform a 1234-bit swap operation on hi; if i % 3 == 2, perform a 1526-bit swap operation on hi; (f)Perform element-by-element h on the H sequence according to bitswap i Perform a shift operation again. If bitswap == 0, then for h i Perform a 1827-bit swap operation; if bitswap == 1, then for h i Perform a 1234-bit swap operation; if bitswap == 2, then for h i Perform a 1526-bit swap operation.
4. A method for image spatial domain encryption and decryption according to claim 3, characterized in that, The steps for encrypting the image data rows include: For the image data sequence D = {d 0 , d 1 , …, d k-1} to be encrypted, perform the XOR operation ( ) on the corresponding elements according to the sequence numbers of the data sequence and the chaotic sequence to encrypt the image data, obtaining the ciphertext E = {e 0 , e 1 , …, e k-1}, that is, D Z = E, that is, e i = d i z i%n , where i = 0, 1, …, k - 1; For the ciphertext sequence E = {e 0 , e 1 , …, e k-1} of the image data, group it by every 256 elements to obtain k / 256 groups of E, denoted as E t , where t = 0, 1, …, k / 256 - 1; when t % 3 = 0, perform scrambling using W00[256], when t % 3 = 1, perform scrambling using W77[256], and when t % 3 = 2, perform scrambling using W1515[256]; The obtained E-Scrambling is the final encryption sequence of the image data.
5. A method for image spatial domain encryption and decryption according to claim 4, characterized in that, The steps for unscrambling the image data include: For the encrypted image data scrambling sequence E-Scrambling, group it by every 256 elements to obtain k / 256 E-Scrambling groups, denoted as E-S t , where t = 0, 1, …, k / 256 - 1; when t % 3 = 0, perform inverse scrambling using W00[256], when t % 3 = 1, perform inverse scrambling using W77[256], and when t % 3 = 2, perform inverse scrambling using W1515[256]; After performing the unscrambling operation, obtain the encrypted sequence E of the image data; The steps for decrypting the image data include: For the encrypted image data sequence E = {e 0 , e 1 , …, e k-1}, perform the exclusive OR operation ( ) on the corresponding elements according to the sequence numbers of the data sequence and the chaotic sequence to decrypt the data and obtain the plaintext D = {d 0 , d 1 , …, d k-1} of the data sequence, that is, E Z = D, that is, d i = e i z i%n , i = 0, 1, …, k - 1.
6. A method for image spatial domain encryption and decryption according to claim 5, characterized in that, Convert the knight's tour sequence generated by the quadratic prediction feedback algorithm based on Warnsdorff's rule into a one-dimensional array form, denoted as W[16×16] = {w 0 , w 1 , ……, w 254 , w 255}, and use W[16×16] to scramble and descramble the image D = {d 0 , d 1 , …, d k-1}; The scrambling algorithm: D-Scrambling[i] = D[(i / 256)*256+W[i%256]], i = 0, 1, …, k - 1; The scrambling algorithm for each group is as follows: E t -Scrambling[i] = E t [W[i]], t = 0, 1, …, k / 256 - 1; i = 0, 1, …, 255; The unscrambling algorithm: D[(i / 256)*256+W[i%256]] = D-Scrambling[i], i = 0, 1, …, k - 1; The scrambling algorithm for each group is as follows: E t [W[i]] = E - S t [i], t = 0, 1, …, k / 256 - 1; i = 0, 1, …, 255.
7. A method for image spatial domain encryption and decryption according to claim 3, characterized in that, x 0 : Initial value, with a value range of (0, 1); μ: Logistic parameter, with a value range of (0, 4]; delay: Delay, the number of iterations for waiting for the chaotic sequence to stabilize; cycle: Period, referring to the length of the obtained chaotic sequence; multipower: Multiplier, the multiplier when calculating the byte chaotic series from the decimal chaotic sequence; bitswap: Bit swap algorithm, providing three swap algorithms: 1827 swap algorithm, 1234 swap algorithm, 1526 swap algorithm.
8. A method for image spatial domain encryption and decryption according to claim 7, characterized in that, x 0 The value of x is 0.5438125; the value of μ is 3.9438125; the value of delay is 100; the value of cycle is 256; the value of multipower is 10 6 ; The 1827 exchange algorithm: Exchange the first and eighth bits, the second and seventh bits, the third and sixth bits, and the fourth and fifth bits of the byte to generate a new byte; 1234 swapping algorithm: Swap the first and second bits, the third and fourth bits, the fifth and sixth bits, and the seventh and eighth bits of a byte to generate a new byte; 1526 swapping algorithm: Swap the first and fifth bits, the second and sixth bits, the third and seventh bits, and the fourth and eighth bits of a byte to generate a new byte.