Color image encryption method and device
Through the SHA-512 algorithm and two-dimensional chaotic pseudo-random number generator combined with the triangular fractal chaos method, the problems of large time consumption and insufficient security in the existing color image encryption methods are solved, and efficient and secure color image encryption is achieved, which is significantly Improves encryption efficiency and security.
Patent Information
- Application Number
- CN202411230203.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-04
- Publication Date
- 2024-12-03
AI Technical Summary
When the existing color image encryption method utilizes the three-channel characteristics of color images, it consumes a lot of time and is insufficient in security, so it cannot effectively utilize the characteristics of color images, resulting in low encryption efficiency and security.
The SHA-512 algorithm is used to process plain text color images, and the subkey set is obtained through hexadecimal number conversion and numerical calculation. The pixel chaotic and channel alternating diffusion are used to perform pixel chaotic and alternating diffusion. Generate encrypted ciphertext color images, improving encryption efficiency and security.
Through triangular fractal confusion and alternating channel diffusion, pixel correlation is reduced, encryption efficiency and security is improved, various attacks are effectively resisted, and the encryption efficiency and security of color images is significantly improved.
Smart Images

Figure CN119071403A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of encryption technology, and in particular to a color image encryption method and device. Background Art
[0002] With the continuous development of the Internet and communication technology, especially the continuous maturity of the Internet of Things and cloud computing, more and more images are widely disseminated and used. Among them, color images are widely used due to their rich information representation advantages compared to grayscale images. From home images to satellite images, since color images can intuitively represent the stored information, once leaked, people can directly obtain the required information through the image, making the protection of color image information security more and more important. Among them, color image encryption methods as a relatively simple technical means to protect image information are valued and studied by scholars at home and abroad.
[0003] At present, the color image encryption architecture is mainly based on the scrambling-diffusion architecture. Scrambling can disrupt the correlation between pixels, and diffusion can change the pixel values to obtain a ciphertext image with uniform pixel distribution. At present, the scrambling method and diffusion method under the scrambling-diffusion framework of color images have some defects. On the one hand, the existing scrambling and diffusion methods cannot make good use of the three-channel characteristics of color images. On the other hand, the current scrambling and diffusion methods in encryption are based on a large number of pseudo-random number sequences, and the three-channel characteristics of color images will lead to the generation of a large number of random number sequences, which increases its time consumption. Therefore, how to connect the three channels of color images and efficient and secure encryption methods has become the encryption demand of the current era. Summary of the invention
[0004] The purpose of this application is to provide a color image encryption method and device, which can improve encryption efficiency and encryption security.
[0005] To achieve the above objectives, this application provides the following solutions:
[0006] In a first aspect, the present application provides a color image encryption method, the color image encryption method comprising:
[0007] Acquire a plaintext color image; the plaintext color image is an M×N three-channel color image;
[0008] The plaintext color image is processed using a SHA-512 algorithm to obtain an initial encryption key;
[0009] Based on the initial encryption key, perform hexadecimal conversion to obtain a final encryption key;
[0010] According to the final encryption key, interception processing and numerical calculation processing are performed to obtain a subkey set; the subkey set is a collection of numerical values of each subkey obtained after interception;
[0011] Calculating a diffusion initial value according to the values of a set number of subkeys in the subkey set;
[0012] A two-dimensional chaotic pseudo-random number generator is used to determine a pseudo-random number sequence set according to the subkey set; the pseudo-random number sequence set includes a pseudo-random number sequence SX and a pseudo-random number sequence SY; the lengths of the pseudo-random number sequence SX and the pseudo-random number sequence SY are both M×N+1;
[0013] Using a triangular fractal scrambling method, pixel scrambling processing is performed on the plaintext color image according to the first element of the pseudo-random number sequence set to obtain a scrambled channel vector; the scrambled channel vector includes: vector RI, vector GI and vector BI;
[0014] According to the M×Nth element in the pseudo-random number sequence set and the diffusion initial value, the scrambled channel vector is subjected to channel alternating diffusion processing to obtain a diffusion channel vector; the diffusion channel vector includes: vector R, vector G and vector B;
[0015] The diffusion channel vector is converted into a channel matrix to obtain an encrypted ciphertext color image.
[0016] Optionally, performing interception processing and numerical calculation processing according to the final encryption key to obtain a subkey set specifically includes:
[0017] According to the final encryption key, 16 subkeys are obtained by intercepting each eight bits, wherein the number of bits of the final encryption key is 128 bits;
[0018] Using formula k i =hexdec(K[1+8*(i-1):8*i]) to perform numerical calculation and obtain the subkey set;
[0019] Among them, k i is the value of the ith subkey; K is the final encryption key; hexdec() is the hexadecimal to decimal function.
[0020] Optionally, calculating the diffusion initial value according to the values of a set number of subkeys in the subkey set specifically includes:
[0021] According to the values of the subkeys of the set number in the subkey set, the formula is adopted:
[0022]
[0023] Calculate diffusion initial values; the set number is 8; the diffusion initial values include: a first diffusion initial value, a second diffusion initial value and a third diffusion initial value;
[0024] Wherein, c1 is the first chaotic initial value used to calculate the diffusion initial value; c2 is the second chaotic initial value used to calculate the diffusion initial value; v 1 is the initial value of the first diffusion; v 2 is the initial value of the second diffusion; v 3 is the initial value of the third diffusion; k 1 is the value of the first subkey; k 2 is the value of the second subkey; k 3 is the value of the third subkey; k 4 is the value of the 4th subkey; k 5 is the value of the fifth subkey; k 6 is the value of the sixth subkey; k 7 is the value of the 7th subkey; k 8 is the value of the 8th subkey; mod() is the remainder function.
[0025] Optionally, using a two-dimensional chaotic pseudo-random number generator to determine a pseudo-random number sequence set according to the subkey set specifically includes:
[0026] The two-dimensional chaotic initial value and chaotic element are determined according to the subkey set; the calculation formula of the two-dimensional chaotic initial value is:
[0027]
[0028] The calculation formula of the chaotic element is:
[0029]
[0030] Using a two-dimensional chaotic pseudo-random number generator, performing iterative processing according to the two-dimensional chaotic initial value and the chaotic element according to set control parameters, and selecting a set number of iterated chaotic elements as the pseudo-random number sequence set;
[0031] Among them, x 0 ,y 0 is the initial value of the two-dimensional chaos; m is the number of chaotic elements that need to be discarded; a is the first control parameter of the chaotic system; b is the second control parameter of the chaotic system; p 1 is the parameter that controls the numerical range of the chaotic pseudo-random number sequence SX; 2 is the parameter that controls the numerical range of the chaotic pseudo-random number sequence SY; floor() is the rounding function; k 9 is the value of the 9th subkey; k 10is the value of the 10th subkey; k 11 is the value of the 11th subkey; k 12 is the value of the 12th subkey; k 13 is the value of the 13th subkey; k 14 is the value of the 14th subkey; k 15 is the value of the 15th subkey; k 16 The value of the 16th subkey.
[0032] Optionally, a triangular fractal scrambling method is used to perform pixel scrambling processing on the plaintext color image according to the first element of the pseudo-random number sequence set to obtain a scrambled channel vector, specifically including:
[0033] Expand the plaintext color image by columns based on three channel matrices to obtain channel vectors rR, rG and rB;
[0034] Determine the target fractal number; the target fractal number is determined based on the number of pixels of the three channel matrices; the calculation formula of the target fractal number is:
[0035]
[0036] Among them, mt is the target fractal number; n is the number of pixels in the channel matrix; is the floor operation; log(·) is the logarithmic function;
[0037] Constructing a fractal triangle; the fractal triangle is obtained by taking the channel vectors rR, rG and rB as the three sides of the triangle in a counterclockwise order;
[0038] According to the first element of the pseudo-random number sequence set, an additional exchange element is calculated; the calculation formula of the additional exchange element is:
[0039]
[0040] Wherein, e is an additional exchange element; mod(·) is a remainder function, |·| is an absolute value; SX(1) is the first element of the pseudo-random number sequence SX; SY(1) is the first element of the pseudo-random number sequence SY;
[0041] Based on the number of exchange elements, the two sides constituting the angle are exchanged in a counterclockwise order; the number of exchange elements is determined according to the length of the additional exchange element and the side of the fractal triangle; the calculation formula for the number of exchange elements is:
[0042]
[0043] Among them, t is the length of the side of the fractal triangle; c is the number of exchange elements;
[0044] The three sides of the fractal triangle are divided by bisection, the front half of the base is rotated clockwise and the lower half of the left side is rotated counterclockwise, two triangles are fracted, and the process returns to "based on the number of exchange elements, the two sides constituting the angle are exchanged in a counterclockwise order", until the number of fractal times reaches the target number of fractal times, and the corresponding channel matrices RM, GM and BM are obtained;
[0045] Expand the channel matrices RM, GM, and BM by rows to obtain three channel vectors cR, cG, and cB. Use cR, cG, and cB as the three sides of a triangle in counterclockwise order to construct a fractal triangle, and return to the step of "calculating additional exchange elements based on the first element of the pseudo-random number sequence set" to obtain the scrambled channel vectors RI, GI, and BI.
[0046] Optionally, based on the number of exchanged elements, two sides constituting the angle are exchanged in a counterclockwise order, specifically including:
[0047] When the fractal order is an odd number, the vector splicing operation method is used to exchange the two sides that form the angle in a counterclockwise order based on the number of exchange elements; the exchange formula used by the vector splicing operation method is:
[0048]
[0049] Among them, swap(·) is a swap operation.
[0050] Optionally, based on the number of exchanged elements, two sides constituting the angle are exchanged in a counterclockwise order, specifically including:
[0051] When the fractal order is an even number, the mirror flip operation method is used to exchange the two sides that constitute the angle in a counterclockwise order based on the number of exchange elements; the exchange formula used by the mirror flip operation method is:
[0052]
[0053] Optionally, performing channel alternating diffusion processing on the scrambled channel vector according to the M×Nth element in the pseudo-random number sequence set and the diffusion initial value to obtain the diffusion channel vector specifically includes:
[0054] According to the M×Nth element {SX(2), SX(3), ..., SX(M×N+1)} and {SY(2), SY(3), ..., SY(M×N+1)} in the pseudo-random number sequence set, the sequence is converted into diffusion sequences DR, DG and DB within a set range;
[0055] The diffusion initial value and the diffusion sequences DR, DG and DB are used to perform channel alternating diffusion on the scrambled channel vector to obtain the diffusion channel vector.
[0056] Optionally, the encryption initial key is a 512-bit hash key value.
[0057] In a second aspect, the present application provides a color image encryption device, the color image encryption device comprising:
[0058] An image acquisition module is used to acquire a plaintext color image; the plaintext color image is an M×N three-channel color image;
[0059] A processing module, used to process the plaintext color image using a SHA-512 algorithm to obtain an initial encryption key;
[0060] A conversion module, used for performing hexadecimal conversion based on the initial encryption key to obtain a final encryption key;
[0061] An interception calculation module, used to perform interception processing and numerical calculation processing according to the final encryption key to obtain a subkey set; the subkey set is a collection of numerical values of each subkey obtained after interception;
[0062] A diffusion initial value calculation module, used to calculate a diffusion initial value according to the values of a set number of subkeys in the subkey set;
[0063] A pseudo-random number sequence set determination module is used to determine a pseudo-random number sequence set according to the subkey set using a two-dimensional chaotic pseudo-random number generator; the pseudo-random number sequence set includes a pseudo-random number sequence SX and a pseudo-random number sequence SY; the lengths of the pseudo-random number sequence SX and the pseudo-random number sequence SY are both M×N+1;
[0064] A scrambling processing module is used to perform pixel scrambling processing on the plaintext color image according to the first element of the pseudo-random number sequence set by using a triangular fractal scrambling method to obtain a scrambled channel vector; the scrambled channel vector includes: a vector RI, a vector GI and a vector BI;
[0065] An alternating diffusion processing module is used to perform channel alternating diffusion processing on the scrambled channel vector according to the M×Nth element in the pseudo-random number sequence set and the diffusion initial value to obtain a diffusion channel vector; the diffusion channel vector includes: vector R, vector G and vector B;
[0066] The ciphertext color image determination module is used to transform the diffusion channel vector into a channel matrix to obtain an encrypted ciphertext color image.
[0067] According to the specific embodiments provided in this application, this application discloses the following technical effects:
[0068] The present application provides a color image encryption method and device, which uses the SHA-512 algorithm to process the plaintext color image, then converts it into hexadecimal, and performs interception processing and numerical calculation processing to obtain a subkey set; a two-dimensional chaotic pseudo-random number generator is used to determine a pseudo-random number sequence set according to the subkey set; a triangular fractal scrambling method is used to perform pixel scrambling processing on the plaintext color image according to the first element of the pseudo-random number sequence set to obtain a scrambled channel vector; according to the M×Nth element in the pseudo-random number sequence set and the initial value of diffusion, the scrambled channel vector is subjected to channel alternating diffusion processing to obtain a diffusion channel vector; the diffusion channel vector is converted into a channel matrix to obtain an encrypted ciphertext color image. The triangular fractal scrambling method relies on the overall irregularity of the fractal to achieve the effect of reducing pixel correlation, wherein the scrambling only requires one variable to control the fractal, and no longer relies on a large number of pseudo-random sequences, thereby improving the efficiency of encryption. At the same time, scrambling and diffusion make good use of the three-channel characteristics of the color image, thereby further improving the security of encryption and effectively resisting various attacks. Therefore, the present application can improve encryption efficiency and encryption security. BRIEF DESCRIPTION OF THE DRAWINGS
[0069] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0070] Figure 1 A flowchart of a color image encryption method provided in an embodiment of the present application;
[0071] Figure 2 A schematic diagram of the encryption operation steps of the color image encryption method provided in an embodiment of the present application;
[0072] Figure 3 It is the histogram statistics of the encrypted color image;
[0073] in, Figure 3 (a) in the figure is the plaintext image; Figure 3 (b) in the figure is the histogram statistics of the plaintext image; Figure 3 (c) in the figure is the ciphertext image; Figure 3 (d) in the figure is the histogram statistics of the ciphertext image; Figure 3 (e) in the figure is the image decrypted using the same key;
[0074] Figure 4This is the key sensitivity analysis effect diagram;
[0075] in, Figure 4 (a) is the ciphertext image resulting from encrypting the plaintext image using the first key; Figure 4 (b) is the ciphertext image obtained by encrypting the plaintext image using a key that differs by 1 bit from the first key; Figure 4 (c) in the figure is the corresponding pixel difference map of the ciphertext image; Figure 4 (d) in FIG. 1 is a histogram of the corresponding pixel difference map of the ciphertext image; Figure 4 (e) a plaintext image resulting from encrypting the plaintext image using the second key; Figure 4 (f) is the plaintext image resulting from encrypting the plaintext image using a key that differs from the second key by 1 bit; Figure 4 (g) in FIG. 1 is the corresponding pixel difference map of the plaintext image; Figure 4 (h) in FIG. 1 is a histogram statistical diagram of the corresponding pixel difference map of the plaintext image;
[0076] Figure 5 This is a diagram showing the robustness analysis of noise and loss attacks using the Lena image as the plaintext image;
[0077] in, Figure 5 (a) shows the decrypted image after being attacked by salt and pepper noise of different degrees; Figure 5 (b) in the figure is the decrypted image after being attacked by Gaussian noise of different degrees; Figure 5 (c) in the figure is the decrypted image after being attacked by different degrees of speckle noise; Figure 5 (d) in the figure is the decrypted image after being affected by different degrees of data loss. DETAILED DESCRIPTION
[0078] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0079] In order to make the above-mentioned objects, features and advantages of the present application more obvious and understandable, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.
[0080] like Figure 1 As shown, an embodiment of the present application provides a color image encryption method, the color image encryption method comprising:
[0081] Step 100: Obtain a plaintext color image. The plaintext color image is an M×N three-channel color image.
[0082] Step 200: Use the SHA-512 algorithm to process the plaintext color image to obtain an initial encryption key. The initial encryption key is a 512-bit hash key value.
[0083] Step 300: Based on the initial encryption key, perform hexadecimal conversion to obtain the final encryption key.
[0084] The final encryption key is converted into 128-bit hexadecimal based on the 512-bit hash key value, with every 4 bits as the basis.
[0085] Step 400: According to the final encryption key, interception processing and numerical calculation processing are performed to obtain a subkey set. The subkey set is a collection of numerical values of each subkey obtained after interception.
[0086] Among them, the subkey set is obtained by performing interception processing and numerical calculation processing according to the final encryption key, which specifically includes:
[0087] Based on the final encryption key, every eight bits are intercepted to obtain 16 subkeys; the number of bits of the final encryption key is 128 bits.
[0088] Using formula k i =hexdec(K[1+8*(i-1):8*] performs numerical calculation and obtains the subkey set.
[0089] Among them, k i is the value of the ith subkey; K is the final encryption key; hexdec() is the hexadecimal to decimal function. The values of the 16 subkeys are k1 to k16. i is the sequence number.
[0090] Step 500: Calculate the diffusion initial value according to the values of a set number of subkeys in the subkey set.
[0091] The calculation of the diffusion initial value according to the values of the subkeys of the set number in the subkey set specifically includes:
[0092] According to the value of the subkey set with a set number of subkeys, the formula is used:
[0093]
[0094] Calculate the diffusion initial value; set the number to 8; the diffusion initial value includes: a first diffusion initial value, a second diffusion initial value and a third diffusion initial value.
[0095] Wherein, c1 is the first chaotic initial value used to calculate the diffusion initial value; c2 is the second chaotic initial value used to calculate the diffusion initial value; v 1 is the initial value of the first diffusion; v 2is the initial value of the second diffusion; v 3 is the initial value of the third diffusion; k 1 is the value of the first subkey; k 2 is the value of the second subkey; k 3 is the value of the third subkey; k 4 is the value of the 4th subkey; k 5 is the value of the fifth subkey; k 6 is the value of the sixth subkey; k 7 is the value of the 7th subkey; k 8 is the value of the 8th subkey; mod() is the remainder function.
[0096] Step 600: using a two-dimensional chaotic pseudo-random number generator to determine a pseudo-random number sequence set according to a subkey set. The pseudo-random number sequence set includes a pseudo-random number sequence SX and a pseudo-random number sequence SY; the lengths of the pseudo-random number sequence SX and the pseudo-random number sequence SY are both M×N+1.
[0097] Among them, a two-dimensional chaotic pseudo-random number generator is used to determine a pseudo-random number sequence set according to a subkey set, specifically including:
[0098] The two-dimensional chaos initial value and chaotic element are determined according to the subkey set; the calculation formula of the two-dimensional chaos initial value is:
[0099]
[0100] The calculation formula of chaos element is:
[0101]
[0102] A two-dimensional chaotic pseudo-random number generator is used to perform iterative processing according to the two-dimensional chaotic initial value and chaotic elements according to set control parameters, and a set number of iterated chaotic elements are selected as a pseudo-random number sequence set.
[0103] Among them, x 0 ,y 0 is the initial value of the two-dimensional chaos; m is the number of chaotic elements that need to be discarded; a is the first control parameter of the chaotic system; b is the second control parameter of the chaotic system; p 1 is the parameter that controls the numerical range of the chaotic pseudo-random number sequence SX; 2 is the parameter that controls the numerical range of the chaotic pseudo-random number sequence SY; floor() is the rounding function; k 9 is the value of the 9th subkey; k 10 is the value of the 10th subkey; k 11 is the value of the 11th subkey; k 12 is the value of the 12th subkey; k13 is the value of the 13th subkey; k 14 is the value of the 14th subkey; k 15 is the value of the 15th subkey; k 16 The value of the 16th subkey.
[0104] Step 700: Using the triangular fractal scrambling method, perform pixel scrambling on the plaintext color image according to the first element of the pseudo-random number sequence set to obtain a scrambled channel vector. The scrambled channel vector includes: vector RI, vector GI and vector BI. Depending on the situation, m rounds of triangular fractal scrambling can be performed to improve the scrambling effect, and m can be any positive integer greater than 0.
[0105] Among them, the triangular fractal scrambling method is used to perform pixel scrambling processing on the plaintext color image according to the first element of the pseudo-random number sequence set, that is, SX(1) and SY(1), to obtain the scrambled channel vector, which specifically includes:
[0106] According to the plaintext color image, the three channel matrices are expanded column by column to obtain channel vectors rR, rG and rB.
[0107] Determine the target fractal number; the target fractal number is determined based on the number of pixels in the three channel matrices; the calculation formula for the target fractal number is:
[0108]
[0109] Among them, mt is the target fractal number; n is the number of pixels in the channel matrix; is the floor operation; log(·) is the logarithmic function;
[0110] Construct a fractal triangle; the fractal triangle is obtained by using the channel vectors rR, rG and rB as the three sides of the triangle in counterclockwise order.
[0111] According to the first element of the pseudo-random number sequence set, the additional exchange element is calculated; the calculation formula of the additional exchange element is:
[0112]
[0113] Wherein, e is an additional exchange element; mod(·) is a remainder function, |·| is an absolute value; SX(1) is the first element of the pseudo-random number sequence SX; SY(1) is the first element of the pseudo-random number sequence SY.
[0114] Based on the number of exchange elements, the two sides that form the angle are exchanged in counterclockwise order; the number of exchange elements is determined based on the length of the additional exchange elements and the side of the fractal triangle; the calculation formula for the number of exchange elements is:
[0115]
[0116] Among them, t is the length of the side of the fractal triangle; c is the number of exchange elements.
[0117] In one embodiment, based on the number of exchanged elements, two sides constituting an angle are exchanged in a counterclockwise order, specifically including:
[0118] When the fractal order is an odd number, the vector splicing operation method is used. Based on the number of exchange elements, the two sides that form the angle are exchanged in a counterclockwise order. The exchange formula used by the vector splicing operation method is:
[0119]
[0120] Among them, swap(·) is a swap operation.
[0121] When the fractal number is even, the mirror flip operation is used. Based on the number of exchanged elements, the two sides that make up the angle are exchanged in a counterclockwise order. The exchange formula used by the mirror flip operation is:
[0122]
[0123] Use the binary search method to split the three sides of the fractal triangle, rotate the first half of the base clockwise and the lower half on the left in a counterclockwise order to fractal out two triangles, and return to "based on the number of exchanged elements, exchange the two sides that constitute the angle in a counterclockwise order" until the fractal number reaches the target fractal number, and obtain the corresponding channel matrices RM, GM and BM.
[0124] Expand the channel matrices RM, GM, and BM by rows to obtain three channel vectors cR, cG, and cB. Use cR, cG, and cB as the three sides of the triangle in counterclockwise order to construct a fractal triangle, and return to the step of "calculating additional exchange elements based on the first element of the pseudo-random number sequence set" to obtain the scrambled channel vectors RI, GI, and BI.
[0125] Step 800: According to the M×Nth element in the pseudo-random number sequence set and the diffusion initial value, the scrambled channel vector is subjected to channel alternating diffusion processing to obtain a diffusion channel vector. The diffusion channel vector includes: vector R, vector G and vector B.
[0126] According to the M×Nth element in the pseudo-random number sequence and the diffusion initial value, the scrambled channel vector is subjected to channel alternating diffusion processing to obtain a diffusion channel vector, which specifically includes:
[0127] According to the M×Nth elements {SX(2),SX(3),…,SX(M×N+1)} and {SY(2),SY(3),…,SY(M×N+1)} in the pseudo-random number sequence set, the sequences are converted into diffusion sequences DR, DG and DB within the set range.
[0128] The diffusion initial value and the diffusion sequences DR, DG and DB are used to perform channel alternating diffusion on the scrambled channel vector to obtain the diffusion channel vector.
[0129] Step 900: Convert the diffusion channel vector into a channel matrix to obtain an encrypted ciphertext color image.
[0130] like Figure 2 As shown, in practical applications, the specific operation steps of the method mentioned in this application can also be as follows:
[0131] S1. Input a plaintext color image I, generate a 512-bit binary initial key through the SHA-512 algorithm, and then convert every four bits into hexadecimal numbers to construct a 128-bit final encryption key K.
[0132] S2. Divide the encryption key into 16 subkeys by intercepting every eight bits, and then calculate the value of the 16 subkeys according to formula (1) as k 1 ~k 16 .
[0133] k i =hexdec(K[1+8*(i-1):8*i]) (1)
[0134] Wherein i=1, 2, 3, ..., 16, hexdec(·) is a hexadecimal to decimal conversion function.
[0135] S3, according to k 1 -k 16 The subkey and pseudo-random number generator obtain two pseudo-random number sequences SX and SY with a length of M×N+1.
[0136] S4. Using k 1 -k 8 Subkey calculation diffusion initial value v 1 、v 2 、v 3 .
[0137] The specific calculation formula is as follows:
[0138]
[0139] S5. Use the triangular fractal scrambling method and two pseudo-random values SX(1) and SY(1) to scramble the pixels of the three channel matrices of the color image I to obtain the scrambled channel vectors RI, GI, and BI. Depending on the situation, m rounds of triangular fractal scrambling can be performed to improve the scrambling effect. At this time, m can be any positive integer greater than 0.
[0140] S6. Use the diffusion initial value and the pseudo-random number sequence {SX(2), SX(3), ..., SX(M×N+1)} and {SY(2), SY(3), ..., SY(M×N+1)} to perform channel alternating diffusion on the scrambled channel vectors RI, GI, BI to obtain the diffused channel vectors R, G, B.
[0141] S7. Convert the channel vectors R, G, and B into a channel matrix to obtain an encrypted ciphertext color image.
[0142] The triangular fractal scrambling in step S5 specifically includes:
[0143] S5.1. Calculate the target fractal number, that is, the maximum fractal number mt, by using formula (2).
[0144]
[0145] Where n is the number of elements in the channel matrix, and its value is M×N. is a floor operation, log(·) is a logarithmic function, where the first argument is the base and the second argument is a real number.
[0146] S5.2. Expand the three channel matrices of the color image I by columns to obtain three channel vectors rR, rG, and rB. Then, in a counterclockwise order, use rR, rG, and rB as the three sides of a triangle to construct a triangle for a fractal.
[0147] S5.3. Use SX(1) and SY(1) to calculate the additional exchange elements. The calculation method is:
[0148]
[0149] Where n is the number of pixels in the channel matrix, is the floor operation, mod(·) is the remainder function, and |·| is the absolute value.
[0150] S5.4. Calculate the number of elements c that need to be exchanged for each fractal. The calculation method is:
[0151]
[0152] Among them, t is the length of the current fractal triangle side, This is a floor operation, and e is an additional exchange element.
[0153] S5.5. Based on the number of exchange elements c, use formula (5) and formula (6) to exchange the two sides that constitute the angle in a counterclockwise order. At the same time, when the fractal order is an odd number, use formula (5) to exchange, otherwise, use formula (6).
[0154]
[0155] Among them, swap(·) is a swap operation, formula (5) is a mirror flip operation, and formula (6) is a vector concatenation operation.
[0156] S5.6. Use the bisection method to divide the three sides of the triangle, then rotate the front half of the base clockwise and the lower half on the left side counterclockwise, so as to fractalize two triangles. Repeat steps S5.4 to S5.6 for these two triangles respectively until the fractal number reaches the maximum fractal number.
[0157] S5.7. End the triangular fractal scrambling process of the channel vector expanded by columns and restore it to the corresponding channel matrices RM, GM, and BM.
[0158] S5.8. Expand the three channel matrices RM, GM, and BM row by row to obtain three channel vectors cR, cG, and cB. Then, use cR, cG, and cB as the three sides of a triangle in a counterclockwise order to construct a triangle for the fractal. Repeat steps S5.3 to S5.6 to obtain the scrambled channel vectors RI, GI, and BI.
[0159] The channel alternating diffusion in step S6 specifically includes:
[0160] S6.1. Convert the pseudo-random number sequences {SX(2), SX(3), ..., SX(M×N+1)} and {SY(2), SY(3), ..., SY(M×N+1)} into diffusion sequences DR, DG and DB in the range of [0, 255] by formula (7).
[0161]
[0162] Wherein, i = 2, 3, ..., M × N + 1. i is the sequence number, DR (i-1), DG (i-1), DB (i-1) are three chaotic diffusion sequences used for diffusion operation.
[0163] S6.2. Use the diffusion initial value and the diffusion sequences DR, DG and DB to perform channel alternating diffusion on the three channel vectors to obtain the diffused channel vectors R, G and B. The diffusion calculation method is:
[0164]
[0165] When i = 1, use formula (8), and when i = 2, 3, ..., M × N, use formula (9). R(i), G(i), and B(i) are the three ciphertext channel vectors obtained after the diffusion operation.
[0166] In addition, step S3 specifically includes:
[0167] S3.1. Calculate the initial value of two-dimensional chaos by formula (10), as follows:
[0168]
[0169] S3.2. Calculate the first m chaotic elements that need to be discarded using formula (11):
[0170]
[0171] S3.3, by selecting appropriate control parameters, the initial value x 0 With y 0 Substitute it into the two-dimensional chaotic system, iterate M×N+1+m times, and select m+1~M×N+1+m chaotic elements as pseudo-random number sequences SX and SY.
[0172] The triangular fractal scrambling proposed in this application combines the overall irregularity of fractal scrambling with the three-channel nature of color images, which better improves the encryption security of color images. At the same time, it avoids being based on a large number of pseudo-random sequences. The scrambling method is only based on two pseudo-random numbers, which improves the encryption efficiency.
[0173] The channel alternating diffusion method proposed in the present application can achieve a change of one pixel while affecting the pixels of three channels, effectively reducing statistical attacks and chosen plaintext attacks.
[0174] In order to verify that the encryption algorithm has excellent encryption security performance, the embodiment of the present application selects three images of different sizes as plaintext images used in the experiment, among which a picture named barche with a size of 256×256 and a picture named lena with a size of 512×512 are selected from the CVG-UGR image database, and a picture named 91 with a size of 512×384 is selected from the UCID image database, and the encrypted ciphertext images are subjected to security analysis.
[0175] 1. Pixel distribution histogram statistical analysis
[0176] Pixel distribution histogram statistics are used to display the pixel distribution of an image. In order to resist statistical analysis attacks and prevent attackers from obtaining its statistical features through statistical analysis, the pixel distribution histogram of the ciphertext image should be horizontal and uniform, while the corresponding plaintext image is often uneven. Figure 3 (b) with Figure 3 (d) shows the histogram statistics of three plaintext images and their corresponding ciphertext images. Figure 3 (a) is the plaintext image; Figure 3 (b) is the histogram statistics of the plaintext image; Figure 3 (c) is the ciphertext image; Figure 3 (d) is the histogram statistics of the ciphertext image; Figure 3 (e) is the image decrypted using the same key.
[0177] Through analysis, it can be seen that for plaintext images with different pixel distributions, after encryption, they are transformed into ciphertext images with uniform pixel distribution, which shows that the encryption algorithm can effectively resist statistical analysis attacks.
[0178] 2. Correlation analysis of adjacent pixels
[0179] For plaintext images, the pixels in the horizontal, vertical, and diagonal directions have high correlation, while ciphertext images often have low pixel correlation to avoid statistical analysis attacks. The correlation between adjacent pixels can be quantified by calculating the Pearson correlation coefficient PCC of adjacent pixels. When the PCC value approaches 1 or -1, it indicates that the adjacent pixels have a high correlation, and when the PCC value approaches 0, it indicates that the adjacent pixels have a low correlation. The closer the PCC value is to 0, the lower the correlation between adjacent pixels, which further indicates that the encryption algorithm has good security performance. The calculation formula of the correlation coefficient PCC is as follows:
[0180]
[0181] in, is the mean value of variable x, is the average value of variable y, u is the number of adjacent pixel pairs selected, l xx is the variance of the variable x, l yy is the variance of the variable y, l xy The covariance between the variables x and y is calculated.
[0182] The PCC values of the three plaintext images and their corresponding ciphertext images in the horizontal, vertical and diagonal directions are calculated respectively, and the results are shown in Table 1.
[0183] Table 1 Correlation table of adjacent pixels in each channel plane of plaintext image and ciphertext image
[0184]
[0185] It can be seen from Table 1 that the PCC values of adjacent pixels in different directions of each plane of the plaintext image are close to 1, indicating that the adjacent pixels have a high correlation, while the PCC value of the ciphertext image is close to 0, indicating that the correlation between adjacent pixels is very low. This shows that this example can reduce the correlation between adjacent pixels of different plaintext images and avoid the possibility of statistical attacks.
[0186] 3. Key sensitivity analysis
[0187] Key sensitivity analysis is used to analyze the sensitivity of encryption algorithms to encryption keys. For encryption algorithms with good key sensitivity, on the one hand, it shows that when two keys with small differences are used to encrypt the same image, the resulting ciphertext images are very different. On the other hand, it shows that when two keys with small differences are used to decrypt the same ciphertext image, the resulting plaintext images are very different. Figure 4 The key sensitivity analysis of this embodiment is demonstrated.
[0188] Figure 4 (a) with Figure 4 (b) The ciphertext image resulting from encrypting the same plaintext image with two keys that differ by 1 bit; Figure 4 (c) Figure 4 The ciphertext image in (a) and Figure 4 (b) The corresponding pixel difference map of the ciphertext image; Figure 4 (d) Figure 4 (c) Histogram statistics; Figure 4 (e) with Figure 4 (f) The plaintext image resulting from decrypting the same ciphertext image using two keys that differ by 1 bit; Figure 4 (g) Figure 4 The plaintext image in (e) is Figure 4 (f) The corresponding pixel difference map of the plaintext image; Figure 4 (h) Figure 4 (g) Histogram statistics diagram.
[0189] Depend on Figure 4 (c) with Figure 4 (d) It can be seen that when the same plaintext image is encrypted with a slightly different key, the encrypted ciphertext image has great differences. Figure 4 (g) with Figure 4 (h) It can be seen that when the same ciphertext image is decrypted using a slightly changed key, the two decrypted plaintext images have great differences. Therefore, this encryption embodiment has good key sensitivity.
[0190] 4. Information entropy randomness analysis
[0191] Information entropy is an indicator used to measure information uncertainty. It can be used to determine the randomness of the pixel distribution of an image. The higher the information entropy, the higher the uncertainty of the image information, which further indicates that the randomness of the pixel distribution of the image is higher. For an 8-bit image, its theoretical information entropy value is 8. That is to say, the closer the information entropy of an image is to 8, the higher the uncertainty of its image information and the randomness of its pixel distribution. The calculation formula for information entropy is as follows:
[0192]
[0193] Where n is the number of pixel bits and P(i) is the probability of occurrence of pixel value i.
[0194] The information entropy of the three plaintext images and their corresponding ciphertext images is calculated respectively, and the results are shown in Table 2.
[0195] Table 2 Information entropy table of each channel plane of plaintext image and ciphertext image
[0196]
[0197] It can be seen from Table 2 that the information entropy of the encrypted ciphertext image is higher than that of the plaintext image, and the information entropy is close to the ideal value of 8. That is to say, this encryption embodiment can disrupt the plaintext image information, making it have good uncertainty and pixel distribution randomness.
[0198] 5. Robustness Analysis
[0199] Image transmission is to convert images into binary data for transmission. In this process, unstable factors such as sensors and transmission media will inevitably cause various noises and data losses of varying degrees. Therefore, for encrypted images, it should be able to effectively resist noise and data loss, that is, the encryption algorithm should have good robustness. In this embodiment of the application, an image named lena is selected as a plaintext image to perform various degrees of noise attacks and loss attacks. Figure 5 The following figure shows the decrypted plaintext image of the encrypted Lena ciphertext image after applying different degrees of noise and data loss attacks, such as Figure 5 (a)- Figure 5 (d). Figure 5 (a) is the decrypted image after being attacked by salt and pepper noise of different degrees; Figure 5 (b) is the decrypted image after being attacked by Gaussian noise of different degrees; Figure 5 (c) Decrypted images after being attacked by different degrees of speckle noise; Figure 5 (d) is the decrypted image after being affected by different degrees of data loss. Figure 5It can be seen that although the ciphertext image suffers from noise or data loss attacks, the decrypted image still retains important information, indicating that the encryption embodiment has good robustness.
[0200] Based on the same inventive concept, the embodiment of the present application also provides a color image encryption device for implementing the color image encryption method involved above. The implementation solution provided by the device to solve the problem is similar to the implementation solution recorded in the above method, so the specific limitations in one or more color image encryption device embodiments provided below can refer to the limitations of the color image encryption method above, and will not be repeated here.
[0201] In an exemplary embodiment, a color image encryption device is provided, the color image encryption device comprising:
[0202] The image acquisition module is used to acquire a plaintext color image; the plaintext color image is an M×N three-channel color image.
[0203] The processing module is used to process the plaintext color image using the SHA-512 algorithm to obtain an initial encryption key.
[0204] The conversion module is used to perform hexadecimal number conversion based on the initial encryption key to obtain the final encryption key.
[0205] The interception calculation module is used to perform interception processing and numerical calculation processing according to the final encryption key to obtain a subkey set; the subkey set is a collection of numerical values of each subkey obtained after interception.
[0206] The diffusion initial value calculation module is used to calculate the diffusion initial value according to the values of the subkeys of a set number in the subkey set.
[0207] The pseudo-random number sequence set determination module is used to determine the pseudo-random number sequence set according to the subkey set using a two-dimensional chaotic pseudo-random number generator; the pseudo-random number sequence set includes a pseudo-random number sequence SX and a pseudo-random number sequence SY; the lengths of the pseudo-random number sequence SX and the pseudo-random number sequence SY are both M×N+1.
[0208] The scrambling processing module is used to adopt a triangular fractal scrambling method to perform pixel scrambling processing on the plaintext color image according to the first element of the pseudo-random number sequence set to obtain a scrambled channel vector; the scrambled channel vector includes: vector RI, vector GI and vector BI.
[0209] The alternating diffusion processing module is used to perform channel alternating diffusion processing on the scrambled channel vector according to the M×Nth element in the pseudo-random number sequence set and the diffusion initial value to obtain a diffusion channel vector; the diffusion channel vector includes: vector R, vector G and vector B.
[0210] The ciphertext color image determination module is used to transform the diffusion channel vector into a channel matrix to obtain the encrypted ciphertext color image.
[0211] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0212] This article uses specific examples to illustrate the principles and implementation methods of this application. The description of the above embodiments is only used to help understand the method and core ideas of this application. At the same time, for those skilled in the art, according to the ideas of this application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting this application.
Claims
1. A color image encryption method, characterized in that: The color image encryption method comprises: Acquire a plaintext color image; the plaintext color image is an M×N three-channel color image; The plaintext color image is processed using a SHA-512 algorithm to obtain an initial encryption key; Based on the initial encryption key, perform hexadecimal conversion to obtain a final encryption key; According to the final encryption key, interception processing and numerical calculation processing are performed to obtain a subkey set; the subkey set is a collection of numerical values of each subkey obtained after interception; Calculating a diffusion initial value according to the values of a set number of subkeys in the subkey set; A two-dimensional chaotic pseudo-random number generator is used to determine a pseudo-random number sequence set according to the subkey set; the pseudo-random number sequence set includes a pseudo-random number sequence SX and a pseudo-random number sequence SY; the lengths of the pseudo-random number sequence SX and the pseudo-random number sequence SY are both M×N+1; Using a triangular fractal scrambling method, pixel scrambling processing is performed on the plaintext color image according to the first element of the pseudo-random number sequence set to obtain a scrambled channel vector; the scrambled channel vector includes: vector RI, vector GI and vector BI; According to the M×Nth element in the pseudo-random number sequence set and the diffusion initial value, the scrambled channel vector is subjected to channel alternating diffusion processing to obtain a diffusion channel vector; the diffusion channel vector includes: vector R, vector G and vector B; The diffusion channel vector is converted into a channel matrix to obtain an encrypted ciphertext color image.
2. The color image encryption method according to claim 1, characterized in that: According to the final encryption key, interception processing and numerical calculation processing are performed to obtain a subkey set, which specifically includes: According to the final encryption key, 16 subkeys are obtained by intercepting each eight bits, wherein the number of bits of the final encryption key is 128 bits; Using formula k i =hedec(K[1+*(i-1):8*i]) performs numerical calculation to obtain a subkey set; Among them, k i is the value of the ith subkey; K is the final encryption key; hexdec() is the hexadecimal to decimal function.
3. The color image encryption method according to claim 2, characterized in that: Calculating the diffusion initial value according to the values of the subkeys of the set number in the subkey set, specifically including: According to the values of the subkeys of the set number in the subkey set, the formula is adopted: Calculate diffusion initial values; the set number is 8; the diffusion initial values include: a first diffusion initial value, a second diffusion initial value and a third diffusion initial value; Among them, c1 is the first chaotic initial value used to calculate the diffusion initial value; c2 is the second chaotic initial value used to calculate the diffusion initial value; v1 is the first diffusion initial value; v2 is the second diffusion initial value; v3 is the third diffusion initial value; k1 is the value of the first subkey; k2 is the value of the second subkey; k3 is the value of the third subkey; k4 is the value of the fourth subkey; k5 is the value of the fifth subkey; k6 is the value of the sixth subkey; k7 is the value of the seventh subkey; k8 is the value of the eighth subkey; mod() is the remainder function.
4. The color image encryption method according to claim 3, characterized in that: Using a two-dimensional chaotic pseudo-random number generator to determine a pseudo-random number sequence set according to the subkey set specifically includes: The two-dimensional chaotic initial value and chaotic element are determined according to the subkey set; the calculation formula of the two-dimensional chaotic initial value is: The calculation formula of the chaotic element is: A two-dimensional chaotic pseudo-random number generator is used to perform iterative processing according to the two-dimensional chaotic initial value and the chaotic element according to set control parameters, and a set number of chaotic elements after iteration are selected as the pseudo-random number sequence set; Among them, x0, y0 are the initial values of the two-dimensional chaos; m is the number of chaotic elements that need to be discarded; a is the first control parameter of the chaotic system; b is the second control parameter of the chaotic system; p1 is the parameter for controlling the numerical range of the chaotic pseudo-random number sequence SX; p2 is the parameter for controlling the numerical range of the chaotic pseudo-random number sequence SY; floor() is the rounding function; k9 is the value of the 9th subkey; k 10 is the value of the 10th subkey; k 11 is the value of the 11th subkey; k 12 is the value of the 12th subkey; k 13 is the value of the 13th subkey; k 14 is the value of the 14th subkey; k 15 is the value of the 15th subkey; k 16 The value of the 16th subkey.
5. The color image encryption method according to claim 1, characterized in that: Using a triangular fractal scrambling method, pixel scrambling processing is performed on the plaintext color image according to the first element of the pseudo-random number sequence set to obtain a scrambled channel vector, specifically including: Expand the plaintext color image by columns based on three channel matrices to obtain channel vectors rR, rG and rB; Determine the target fractal number; the target fractal number is determined based on the number of pixels of the three channel matrices; the calculation formula of the target fractal number is: Among them, mt is the target fractal number; n is the number of pixels in the channel matrix; is the floor operation; log(·) is the logarithmic function; Constructing a fractal triangle; the fractal triangle is obtained by taking the channel vectors rR, rG and rB as the three sides of the triangle in a counterclockwise order; According to the first element of the pseudo-random number sequence set, an additional exchange element is calculated; the calculation formula of the additional exchange element is: Wherein, e is an additional exchange element; mod(·) is a remainder function, |·| is an absolute value; SX(1) is the first element of the pseudo-random number sequence SX; SY(1) is the first element of the pseudo-random number sequence SY; Based on the number of exchange elements, the two sides constituting the angle are exchanged in a counterclockwise order; the number of exchange elements is determined according to the length of the additional exchange element and the side of the fractal triangle; the calculation formula for the number of exchange elements is: Where t is the length of the side of the fractal triangle; c is the number of exchange elements; Use the binary division method to split the three sides of the fractal triangle, rotate the first half of the base clockwise and the lower half of the left side counterclockwise, fractalize two triangles, and return to "based on the number of exchange elements, exchange the two sides that constitute the angle in a counterclockwise order" until the fractal number reaches the target fractal number, and obtain the corresponding channel matrices RM, GM and BM; Expand the channel matrices RM, GM, and BM by rows to obtain three channel vectors cR, cG, and cB. Use cR, cG, and cB as the three sides of the triangle in counterclockwise order to construct a fractal triangle, and return to the step of "calculating additional exchange elements according to the first element of the pseudo-random number sequence set" to obtain the scrambled channel vectors RI, GI, and BI.
6. The color image encryption method according to claim 5, characterized in that: Based on the number of exchanged elements, the two sides that form the angle are exchanged in counterclockwise order, including: When the fractal order is an odd number, the vector splicing operation method is used to exchange the two sides that form the angle in a counterclockwise order based on the number of exchange elements; the exchange formula used by the vector splicing operation method is: Among them, swap(·) is a swap operation.
7. The color image encryption method according to claim 6, characterized in that: Based on the number of exchanged elements, the two sides that form the angle are exchanged in counterclockwise order, including: When the fractal order is an even number, the mirror flip operation method is used to exchange the two sides that form the angle in a counterclockwise order based on the number of exchange elements; the exchange formula used by the mirror flip operation method is:
8. The color image encryption method according to claim 1, characterized in that: According to the M×Nth element in the pseudo-random number sequence set and the diffusion initial value, the scrambled channel vector is subjected to channel alternating diffusion processing to obtain a diffusion channel vector, specifically including: According to the M×Nth element {SX(2), SX(3), ..., SX(M×N+1)} and {SY(2), SY(3), ..., SY(M×N+1)} in the pseudo-random number sequence set, the sequence is converted into diffusion sequences DR, DG and DB within a set range; The diffusion initial value and the diffusion sequences DR, DG and DB are used to perform channel alternating diffusion on the scrambled channel vector to obtain the diffusion channel vector.
9. The color image encryption method according to claim 1, characterized in that: The encryption initial key is a 512-bit hash key value.
10. A color image encryption device, characterized in that: The color image encryption device comprises: An image acquisition module is used to acquire a plaintext color image; the plaintext color image is an M×N three-channel color image; A processing module, used for processing the plaintext color image using a SHA-512 algorithm to obtain an initial encryption key; A conversion module, used for performing hexadecimal conversion based on the initial encryption key to obtain a final encryption key; An interception calculation module, used to perform interception processing and numerical calculation processing according to the final encryption key to obtain a subkey set; the subkey set is a collection of numerical values of each subkey obtained after interception; A diffusion initial value calculation module, used to calculate a diffusion initial value according to the values of a set number of subkeys in the subkey set; A pseudo-random number sequence set determination module is used to determine a pseudo-random number sequence set according to the subkey set using a two-dimensional chaotic pseudo-random number generator; the pseudo-random number sequence set includes a pseudo-random number sequence SX and a pseudo-random number sequence SY; the lengths of the pseudo-random number sequence SX and the pseudo-random number sequence SY are both M×N+1; A scrambling processing module is used to perform pixel scrambling processing on the plaintext color image according to the first element of the pseudo-random number sequence set by using a triangular fractal scrambling method to obtain a scrambled channel vector; the scrambled channel vector includes: a vector RI, a vector GI and a vector BI; An alternating diffusion processing module is used to perform channel alternating diffusion processing on the scrambled channel vector according to the M×Nth element in the pseudo-random number sequence set and the diffusion initial value to obtain a diffusion channel vector; the diffusion channel vector includes: vector R, vector G and vector B; The ciphertext color image determination module is used to transform the diffusion channel vector into a channel matrix to obtain an encrypted ciphertext color image.
Citation Information
Cited By
Color image encryption method and system based on three-dimensional dynamic pixel code replacement
CN120263916A
