Jia Liu,Haiping Chang,Weiyu Ran,Erfu Wang
Research on Improved DNA Coding and Multidirectional Diffusion Image Encryption Algorithm
image encryption,DNA coding,multidirectional diffusion
In order to make the security and operating efficiency of an image encryption algorithm coexist, this study proposed a color image encryption algorithm with improved DNA coding and rapid diffusion. During the stage of improving DNA coding, the chaotic sequence was used to form a look-up table to complete the base substitutions. In the replacement process, several encoding methods were combined and interspersed to make the randomness higher, thereby improving the security performance of the algorithm. In the diffusion stage, three-dimensional and six-directional diffusion was performed on the three channels of the color image by taking the matrix and the vector as the diffusion unit successively. This method not only ensures the security performance of the algorithm, but also improves the operating efficiency in the diffusion stage. From the simulation experiments and performance analysis, it was shown that the algorithm has good encryption and decryption effects, large key space, high key sensitivity, and strong security. The algorithm can effectively resist differential attacks and statistical attacks, and has good robustness.
Research on Improved DNA Coding and Multidirectional Diffusion Image Encryption Algorithm

In order to make the security and operating efficiency of an image encryption algorithm coexist, this study proposed a color image encryption algorithm with improved DNA coding and rapid diffusion. During the stage of improving DNA coding, the chaotic sequence was used to form a look-up table to complete the base substitutions. In the replacement process, several encoding methods were combined and interspersed to make the randomness higher, thereby improving the security performance of the algorithm. In the diffusion stage, three-dimensional and six-directional diffusion was performed on the three channels of the color image by taking the matrix and the vector as the diffusion unit successively. This method not only ensures the security performance of the algorithm, but also improves the operating efficiency in the diffusion stage. From the simulation experiments and performance analysis, it was shown that the algorithm has good encryption and decryption effects, large key space, high key sensitivity, and strong security. The algorithm can effectively resist differential attacks and statistical attacks, and has good robustness.

People are constantly exchanging information using the Internet and smartphones due to the rapid expansion of the Internet and the popularity of smartphones. While there is a lot of information sharing and convenience, a lot of data have been leaked, tampered with, and counterfeited. As an essential carrier of information interaction, digital images mainly comprise grayscale and color images. Compared with grayscale images, color images contain more information and account for most digital images. As a result, developing a good color image encryption technique is critical. Encryption technology transforms ordinary images into noise-like or texture-like secret images, using keys and encryption algorithms to provide safe communication. The original image can only be recovered after decryption if the proper key is obtained. At the same time, because of the effect and interference of equipment, lighting, and other settings, encrypted images are easily lost or contaminated by numerous sounds when transferred via networks, which directly impacts whether the encrypted images can be correctly decoded. Encryption security is lost when data are intercepted, manipulated, or deciphered. It is a matter of time before any intercepted image data are deciphered. In order to ensure that the encrypted images are adequately safe, information embedding can be chosen to decrease third-party attention. Of course, the most straightforward approach is to make the encryption algorithm sophisticated enough, the key space wide enough, and the method robust enough to withstand brute force attacks, differential attacks, statistical attacks, and others. Therefore, an encryption algorithm that is complex enough to ensure operational efficiency and has strong anti-attack and anti-interference performance has always been the research goal. In recent years, developing a means to ensure the secure storage and transmission of digital photographs over the Internet has become a research hotspot [1,2,3]. Image data have characteristics of a two-dimensional structure, high redundancy, and large data volume. Thus, encryption algorithms such as 3DES and AES are no longer applicable. Image encryption algorithms mainly include scrambling, replacement, and diffusion algorithms. Among the scrambling methods, encryption algorithms such as Zigzag scan [4,5,6], Arnold transform [7,8], and magic square transform [9] can successfully disrupt visual information; however, they have difficulty withstanding modern cryptanalysis tools. DNA is a natural information storage medium with the advantages of high storage density, long storage time, and low loss rate [10,11]. Researchers have found that data can be converted into sequence information of different bases in the DNA molecular chain through DNA algorithms for replacement and storage, especially in image processing [12,13,14]. However, the traditional DNA encoding algorithm is weak in its anti-exhaustive attack ability, due to its fixed DNA base complementary pairing criterion and base operation criterion, and is prone to security risks. Diffusion technology hides the information of plaintext pixels in as many pixels as possible, without changing the position of the pixels, to improve the security of the encryption scheme. However, the traditional one-dimensional diffusion encryption algorithm is inefficient when dealing with images that have large amounts of data. It has been discovered that chaotic systems that are highly sensitive to changes in initial values produce a significant number of excellent pseudorandom sequences that naturally comply with the laws of scrambling, substitution, and diffusion [15,16,17,18,19,20,21]. As chaotic anti-control technology matures, more researchers are committed to harnessing chaotic systems to build novel encryption algorithms that totally conceal the statistical properties of original and encrypted images. Pak [22] created a simple and effective chaotic system using the output sequence difference of two identical one-dimensional chaos maps, which can provide a one-dimensional chaotic system with superior chaotic performance and a longer chaotic range than prior chaotic maps. Ratna [23] proposed an image encryption algorithm based on a chaotic system and DNA sequence operation that uses wave transmission properties to develop a new DNA horizontal wave displacement scheme and horizontal progressive image diffusion method that can effectively resist chosen plaintext attacks and known plaintext attacks. Liu [24] encoded, obfuscated, and diffused digital images via hyperchaotic dynamic DNA mechanisms. This encryption procedure is robust, since dynamic DNA diffusion is estimated in the blocks. The hyperchaotic system has a complex structure, can stretch and fold in numerous directions, and can keep good random features in the digital system. Nevertheless, the operational efficiency is considerably lowered while improving safety performance, and the practical value is low. Jin Jianguo [25] increased the algorithm’s security using chaotic dynamic randomization and random modulation FRFT rotation factor; however, the time complexity is significant. Although Zhao’s [26] ciphertext block encryption mode maintains the algorithm’s security performance, the proposed diffusion mechanism is complex, resulting in low operating efficiency. Ünal [27] partitioned multi-threaded pictures, which considerably improves algorithm efficiency but does not provide a spreading method between separate threads, making differential attacks harder to resist. Due to the disadvantages of existing picture encryption methods, such as slow and insufficient pixel diffusion speed, Ge Bin [28] presented a four-way diffusion approach to boost the diffusion speed of the matrix rapidly. In order to make the encryption algorithm have sufficient security and operating efficiency, based on the four-dimensional hyperchaotic system, this study proposed an improved DNA encoding algorithm and a three-dimensional six-way diffusion algorithm. In DNA encoding, the chaotic sequence is used to generate a lookup table, and the base substitution is realized by indexing the base pairs stored in the lookup table. In the diffusion stage, the three channels of the color image are rapidly diffused with a matrix and vector as the diffusion unit. This method ensures the complexity of the algorithm, and improves its operating efficiency in the diffusion stage.

Vladimir Igorevich Arnold, a Russian mathematician, proposed Arnold mapping. Since Arnold frequently used cat photos as examples when teaching, the technique is known as “cat mapping.” This mapping approach scrambles the position of each pixel in an image by continuously folding, stretching, and transforming in a small area. As a mainstream dislocation approach, the algorithm is defined as follows, and its mapping variation is shown in Figure 1. The pixel blocks in Figure 1 are stretched and distributed to other areas, such as A, B, C, D, and then folded back to the original pixel blocks. where a, b, and N are positive integers, and N is the width of the square matrix, xn and yn represent the position of pixels in the grayscale image before transformation, while xn+1 and yn+1 represent the positions of pixels after transformation. Figure 1 shows that the pixel position of the input image is extended by multiplying the matrix, and then the position is modulo the square matrix width of the stretched value returned to the original matrix. At the same time, Arnold mapping is a one-to-one mapping, meaning that each point in the matrix will shift to another point in the matrix to fulfill the goal of pixel position diffusion. To restore the scrambled position, Arnold mapping inverse change can be performed using Equation (2): where parameters a, b and N are consistent with Formula 1, xn and yn represent the position of a pixel in the grayscale image after replacement, and xn+1 and yn+1 represent the position of a pixel restored. Although the Arnold mapping algorithm is basic and quick to implement, it is confined to square matrix transformations and has the flaws of periodicity and a fixed starting point.

The hyperchaotic Lorenz system is an evolution of the 3DLorenz system. Linear feedback is added on the basis of the 3DLorenz system, as shown in Equation (3): where, a, b, c, and r are the coefficients of the 4DLorenz system. When , , , , or , the system is in a hyperchaotic state. When , there are four Lyapunov exponents in this system, which are 0.3381, 0.1586, 0, and −15.1752, with two of them being bigger than zero. The high-dimensional hyperchaotic system has a more complicated structure than the low-dimensional chaotic system, and the generated sequence is more unpredictable, making it more suited for picture encryption.

The traditional DNA-encoding image encryption algorithm consists of three stages: encoding, base operation, and decoding. The base operation consists mostly of the XOR operation, addition operation, and subtraction operation. However, because of the fixed base complementary pairing requirement and base operation criterion of DNA coding, the anti-brute-force attack capacity of the DNA coding algorithm is weak, making security vulnerabilities easy to introduce. In this study, a novel image encryption technique based on the DNA coding strategy is proposed. This technique uses a system function to form the lookup table, decomposes pixel values into row coordinates and column coordinates, and indexes the lookup table to obtain the base pairs stored in the lookup table for base substitution. Several coding methods are merged and interleaved during the substitution process, increasing the randomness and improving the security performance of the algorithm.

DNA is made up of four deoxynucleotides: adenine (A), cytosine (C), guanine (G), and thymine (T). The chemical structure of the base defines the principle of base complementary pairing, which is two hydrogen bonds between A and T and three hydrogen bonds between G and C. Base operation and permutation can store binary information if a base is represented by a 2-bit binary number. A grayscale image pixel can be represented as an 8-bit binary value, which can be translated into four bases for calculation. There are a total of base combinations for a pixel based on the complementary pairing of base pairs and , and assuming the complementary pairing principle of number pairs is and , there are only eight combinations that meet the complementary pairing principle of base pairs, as shown in Table 1: An encoding mode is selected according to the chaotic sequence value and encodes the pixel value. For example, the pixel value 27 has the binary form of “00011011”. With the first encoding way, four bases “ACGT” can be obtained; if the eighth encoding mode is selected, the encoding is “TGCA”.

The lookup table is generated in the following way: a pseudo-random permutation of integers from 1 to n can be generated using the MATLAB function randperm(n), whose pseudo-random result is determined by the seed of the random number generator, while the seed of the random number generator can be specified by the function rng(seed). When the chaotic value is substituted into the function rng(seed) as a seed, the corresponding pseudo-random sequence can be generated. For example, the chaotic values 125 and 201 are taken as the seeds of the random number generator, respectively, to obtain a random number sequence of length 16. Subtract 1 from the sequence value and turn it into matrix 1 and matrix 2, as shown in Figure 2. The two random matrices are encoded by DNA encoding methods based on chaotic values, and lookup Table 1 and lookup Table 2 are obtained. Figure 3 shows the results of matrix 1 and matrix 2 encoded by the third and fifth encoding modes, respectively. In Figure 3, the blue part is the storage area of the lookup table, in which base pairs are stored, and the colorless part is the row and column coordinates of the lookup table. The pixel value 27 is encoded to obtain the base “TGCA”; “T” of “TGCA” is taken as the row address of lookup Table 1, and “G” is taken as the column address of lookup Table 1, to obtain the base pair “GC”. “C” is used as the row address of lookup Table 2, and “A” is used as the column address of lookup Table 2 to obtain the base pair “AG”. The search eventually replaces “TGCA” with “GCAG.” Since each pair of bases in the lookup table is unique, the decryption operation can be realized using find(base) to obtain the column and row coordinates of the stored values by knowing the stored values in the lookup table.

Base operation is based on binary mathematical operation, and its operation rules include XOR, XNOR, addition, and subtraction operations. Take encoding mode 1 as an example: “00” corresponds to base A, and “01” corresponds to base C, if “00” is different from “01” or “01” is the corresponding base C. Table 2 shows the base XOR and XNOR rules in encoding mode 1. Table 3 shows the operation rules of base addition and subtraction in coding method 1. The chaotic values in the range 0–255 are encoded to obtain four bases, and four new bases can be obtained by performing base operations with the bases replaced in the previous section. DNA decoding is the reverse process of DNA coding, which translates the transformed bases into binary numbers in any encoding way to realize the transformation of the pixel values. For example, the pixel value 27 is encoded into “TGCA” in the first encoding mode, and the result obtained through substitution and base operation is “GCAG”. The result obtained through reverse decoding in the second encoding mode is “01100001”, which is the decimal number 97.

The above-mentioned DNA coding approach can only change pixel values point-by-point, and cannot transmit the influence of a single pixel to the entire world. The traditional diffusion method combines forward diffusion and reverse diffusion, converting the original image into a one-dimensional sequence before performing multiple rounds of replacement, based on the encrypted image grouping link mode, to complete the global diffusion of pixel information on the encrypted image. Study [28] developed a two-dimensional and four-way rapid diffusion approach that used row and column vectors as computation units to boost diffusion efficiency. The approach was improved in this study to make the four-way diffusion algorithm of a single plane applicable to the diffusion between the three channels of a color image, and realizes the avalanche effect that the change in any pixel value can cause the change in the pixel value of the three planes.

According to the algorithm provided in study [28], four sequences of length M, M, N, and N are intercepted from the chaotic sequence and employed as the initial diffusion sequences in the right, left, upper, and lower diffusion directions, respectively. At the same time, the chaotic sequence of length is changed into a chaotic matrix of size , which serves as the foundation for four-way diffusion. According to study [28], row vector and column vector were used as the units of measurement, in conjunction with the beginning sequence and the basis, and four repetitions of diffusion were carried out sequentially through the front, back, left, and right. Figure 4 depicts the algorithm flow. As shown in Figure 4, the value of every pixel in a grayscale image can be diffused across the entire matrix, following two-dimensional and four-way diffusion.

The combination of diffusion between planes with two-dimensional and four-way diffusion results in three-dimensional and six-way diffusion. Using the pixel points at the appropriate places of the three channels R, G, and B as an example, the chaotic sequence x, y, z, and w with length is also turned into a chaotic matrix of size , as shown in Figure 5. With chaotic matrix x as the basis and color image R and G channels as the unit of operation, the diffusion matrix K1 is obtained by top-down diffusion through Equation (4): With chaotic matrix y as the basis and channels K1 and B as the units of operation, the diffusion matrix K2 is obtained by top-down diffusion through Equation (5): According to the method of [28], the matrix K2 is diffused in two dimensions and four directions to obtain the matrix K3. Using the chaotic matrix z as the base and the two matrices K3 and K1 as the operation units, bottom-up diffusion is performed through Equation (6) to obtain the diffusion matrix K4. Taking the chaotic matrix w as the base, and the two matrices K4 and R as the units of measurement, bottom-up diffusion is carried out through Equation (7) to obtain the diffusion matrix K5. The matrices K5, K4, and K3 are used to replace the original R, G, and B three channels to synthesize a color image. Thus far, the color image’s three-dimensional and six-way diffusion is complete, and changes to pixels in any channel of the color image can affect pixels in all channels. Equation (8) shows the inverse diffusion of the upper and lower diffusions of the channel during the decryption process: where X is the basis of the current diffusion matrix. Firstly, the three channels K5, K4, and K3 are extracted from the encrypted image, and matrices K5 and K4 can be substituted into formulas X1 and X2 to solve the matrix R, where . Substituting K4 and K3 into X1 and X2 solves the matrix K1, where . The matrix K3 is reduced to matrix K2 via inverse four-way diffusion. Substituting K2 and K1 into X1 and X2 solves the matrix B, where . Then, matrices K1 and R are substituted into X1 and X2 to obtain matrix G, where . The reductions in matrices R, G, and B are realized. Reference [28] pointed out that the time complexity of the algorithm in the gray image diffusion process is only O(2 M + 2 N), which has obvious advantages compared with the complexity of the existing algorithm O(2 MN). In this research, the algorithm was extended to three-dimensional space so that color images are also applicable, and the corresponding time complexity is only O(2 M + 2 N + 4), while the time complexity of study [28] was O(3 × (2 M +2 N)). If the grayscale image is divided into blocks and then diffused using the three-dimensional six-direction algorithm, the algorithm’s time complexity is smaller.

Before picture encryption, the average pixel values of the three channels, R, G, and B, were determined and quantized into a fractional mean in the range of 0–1. Its calculating formula is shown in Equation (9): where M and N are the plaintext image’s length and width, i and j are pixel coordinates, and p are pixel points in the equation. The mean value of each channel is taken as the initial values x0, y0, and z0 of the four-dimensional hyperchaotic system. The value of w0 is set by the user. The chaotic system is pre-iterated 800 times to eliminate the transient effect and make the system enter the chaotic state entirely. Then, it iterates 2 × M × N times to produce four chaotic sequences x, y, z, and w of length 2 × M × N. The first 2 × M × N sequence values are intercepted to obtain x1, y1, z1, and w1, which are used to realize DNA coding. The last M × N sequence values x2, y2, z2, and w2 are used for three-dimensional six-way diffusion. Equation (10) is used to modulo the chaotic sequences x1, y1, z1, and w1 against 224 to obtain the sequence X1, Y1, Z1, and W1. The chaotic sequences x2, y2, z2, and w2 are quantified by Equation (11) to obtain the sequences X2, Y2, Z2, and W2, which are used to realize three-dimensional and six-way diffusion.

The encryption algorithm procedure described in this study is separated into three stages: scrambling, DNA coding, and three-dimensional and six-way diffusion. Figure 6 depicts the specific flow chart. In order to better describe the encryption flow chart, the following is divided into eight steps for a specific description. Step 1: Obtain the initial values of the four-dimensional hyperchaotic system x0, y0, and z0 from the original image, and set , system parameters , , , and . According to the preprocessing process mentioned in Section 5.1, the chaotic sequences X1, Y1, Z1, and W1, and X2, Y2, Z2, and W2 are obtained. Step 2: Set Arnold mapping coefficients , , and the number of scrambles , and then scramble channels R, G, and B of the original image, respectively. Step 3: Generate lookup Table 1 and lookup Table 2. Convert X1 to a 24-bit binary number. Take X1[24:20] as the seed of the random number generator, then generate matrix 1 using the function randperm(seed), and encode matrix 1 by the encoding mode selected by X1[19:17] to obtain lookup Table 1; X1[16:12] is used as the seed of the random number generator, and generates matrix 2 via the function randperm(seed), and the encoding mode chosen by X1[11:9] encodes matrix 2 to obtain lookup Table 2. Similarly, sequences Y1 and Z1 are used for the lookup table generation of G and B channels. Step 4: X1[8:6] selects the encoding method to encode the pixel value of the R channel and obtains four bases. The first two bases are used as the row coordinates and column coordinates of lookup Table 1, and replace index values with base pairs stored in a lookup table. The last two bases act on lookup Table 2 for indexing and replacing. Similarly, the sequences Y1 and Z1 act on the G channel and B channel to achieve base substitution. Step 5: Convert W1 to a 24-bit binary number. Cut the sequence W1 into W1[24:17], W1[16:9], and W1[8:1]. X1[5:4] selects the encoding method to encode W1[24:17], and the encoded base selects the base operation method according to X1[2:1] and performs base operation with the replacement value in the previous step. W1[16:9] and W1[8:1] do the same with chaos Y1 and Z1. Step 6: According to X1[3:1], the encoding method is selected, and the base after the base operation is decoded into binary and converted to decimal to obtain the pixel value R1. G1 and B1 are obtained in the same way according to the sequence values Y1 and Z1. Step 7: According to the three-dimensional and six-way diffusion strategy proposed in this study, chaotic sequences X2, R1, and G1 are used to obtain matrix K1, and chaotic sequences Y2, K1, and B1 are used to obtain matrix K2. K2 is diffused in two dimensions to obtain K3. The chaotic sequences Z2, K3, and K1 are used to obtain matrix K4, and the chaotic sequences W2, K4, and R1 are used to obtain matrix K5. Step 8: Synthesize the K3, K4, and K5 channels into a color ciphertext image.

This study used color images with sizes 512 × 512 as the original images for testing the algorithm performance, which mainly included images Lena, Peppers, and Baboon. The algorithm’s key space, key sensitivity, differential attack resistance, histogram, adjacent pixel correlation, information entropy, and robustness were evaluated and compared.

Figure 7 depicts the results of the algorithm’s encryption and decryption of Lena, Peppers, and Baboon color images. As seen in Figure 7, the encrypted images in Figure 7b,e,h are jumbled, and it is impossible to see any information from the original image with the naked eye. The decoded photos in Figure 7c,f,i were compared to the corresponding original images without missing data, allowing the original images to be recovered without loss.

The key space refers to the set of all possible keys that can be used to generate the key. The size of the key space depends on the length of the security key, and is one of the most important characteristics that determine the strength of the cryptosystem. The key space required by the encryption algorithm to effectively resist brute force attacks is at least 2100. The algorithm key proposed in this paper includes Arnold scrambling coefficients , , and scrambling number ; the initial values x0, y0, z0 of the four-dimensional hyperchaotic system are calculated by the original image, and the initial value is set by oneself. Moreover, the system coefficient numbers are , , , and . If the accuracy of the computer is , the key space of the encryption algorithm proposed in this paper is at least and much larger than 2100; thus, the algorithm can effectively prevent brute force attacks.

As a result of key sensitivity, a tiny change in the key can result in an entirely different encryption result. The key sensitivity of chaotic cryptography includes the sensitivity of the initial state of the chaotic system and the sensitivity of the control parameters. Sensitivity is assessed using two parameters: pixel number rate of change (NPCR) and uniform average change intensity (UACI). Assuming that C1 is the encrypted picture corresponding to the original image and C2 is the encrypted image after the key is changed, NPCR and UACI denote the number of changing pixels and the average number of changing intensities between two encrypted images, C1 and C2. Their corresponding ideal values are and , respectively. The calculation equation is as follows: where M and N are the width and height of the image, and i and j are the index values of the rows and columns. The variable is defined as Equation (13): Accordingly, UACI can be used to measure the mean value of the contrast intensity of the color component, and its formula is shown in Equation (14): From the encryption level, Figure 8, Figure 9 and Figure 10 show the encrypted image C1 of Lena, the encrypted image C2 after the disturbance of key x0 and w0 is increased by 10−14, and the disturbance of scrambling coefficient a is increased by 1, as well as the difference between C1 and C2 of the encrypted image. From the difference image (d), it can be seen that the encrypted image C2 is completely different from the encrypted image C1 after the disturbance of key x0 and w0 is increased by 10−14, and the disturbance of scrambling coefficient a is increased by 1. Table 4 shows the NPCR and UACI values between C1 and C2 of encrypted images after the perturbation of different keys is added, respectively. From the data provided in Table 4, it can be observed that when the initial values of the chaotic system x0, w0 increase by 10−14 disturbance and the Arnold scrambling coefficient a increases by 1, the NPCR and UACI values between the corresponding ciphertext image and the original ciphertext image are close to ideal values. The minimum difference between the NPCR value of each channel and the ideal value of 99.6094% is 0.0001%, and the maximum difference is 0.0138%. The maximum difference between UACI and the ideal value of 33.4635% is 0.1045%, and the minimum difference is 0.0151%. It shows that the corresponding ciphertext image after the minimum precision perturbation of the key of the algorithm changes greatly compared with the original ciphertext image, which proves that the key sensitivity of the algorithm is very strong. From the perspective of the decryption level, when encrypting, the key provided by the algorithm is used to encrypt, and when decrypting, the key w0 is increased by 10−14 perturbation and then the decryption operation is performed. The results are shown in Figure 11. Figure 11c,d show that when the difference between the key and the original key during decryption is 10−14, the decrypted image is absolutely irrelevant to the encrypted image. As a result of the decryption level analysis, the key to this algorithm is quite sensitive.

The differential attack is a powerful approach for cracking encrypted images. It means that the attacker makes subtle changes to the original image data, encrypts it with the proposed encryption algorithm, determines the relationship between the original image data and the encrypted image data by comparing the two encrypted images, and uses this relationship and rule to crack the encrypted image. A differential attack is a type of ciphertext attack. The performance of the anti-differential attack is determined by the initial image sensitivity. NPCR and UACI can also be used to calculate the size difference between two encrypted images. When the difference is bigger, the NPCR and UACI are closer to the ideal values of 99.6094% and 33.4635%, respectively, indicating that the anti-differential attack capability of the system is stronger. In order to test the anti-differential attack performance of the algorithm, the Lena color image with a size of 512 × 512 was selected for detection and comparison. First, 100 pixels were randomly selected in any channel of the image, and a pixel value was added or subtracted in turn to fine-tune; then, the fine-tuned plaintext image was encrypted using the algorithm proposed in this study to obtain the ciphertext C2; then, the original ciphertext substituted text C1 and fine-tuned ciphertext C2 into Equations (13)–(15), the NPCR and UACI values of the two were calculated each time, and finally the average values of NPCR and UACI were calculated 100 times. The comparison of test results with other algorithm results is shown in Table 5. In order to reflect the anti-differential attack ability of the algorithm in this research, Table 5 provides the NPCR and UACI values of different algorithms. By observing the data, it can be found that each algorithm’s NPCR and UACI values are close to the ideal values of 99.6094% and 33.4635%, indicating that each algorithm has a better ability to resist differential attacks. In order to further compare the performance of the different algorithms, the average difference between the NPCR and UACI of the R, G, and B channels and the ideal value was calculated. It can be found that the average difference between the NPCR and the ideal value of the algorithm in this study is 0.00036, and the average difference between UACI and the ideal value is 0.0211; study [29] corresponds to 0.0139 and 0.0131; study [30] corresponds to 0.0010 and 0.0464; study [31] corresponds to 0.0089 and 2.9959; study [31] corresponds to 0.0115 and 3.1368. From this, it can be found that this algorithm’s NPCR and UACI values are closer to the ideal values than those of the other encryption algorithms. This shows that after fine-tuning a specific pixel of the plaintext image, the algorithm achieves a more significant transformation of the ciphertext image, which proves that the algorithm is more resistant to differential attacks.

The histogram displays the image’s statistical data, which can intuitively indicate the distribution of each gray value in the image. The histograms of the original image show clear statistical trends. The statistical analysis attacker can compare the ciphered image to its statistical law and determine the transformation relationship between the original and ciphered images. To withstand statistical attacks, the encrypted image’s histogram must be uniform and completely different from the original image’s histogram. Figure 12 depicts the histograms of the three channels R, G, and B of the original and encrypted Lena images. Figure 12 shows that the three channels of the encrypted image, R, G, and B, are all near a horizontal line, and are completely distinct from the original image, which may effectively resist statistical attacks.

Correlation analysis involves the examination of two or more correlated variable elements in order to determine the degree of similarity between variables. Since the association between neighboring pixels in original photographs is very strong, leaking a pixel will result in the leakage of surrounding pixel information. This feature can be used by attackers to infer the pixel value surrounding the leaked pixel. To resist statistical attacks, a decent encryption method can disrupt the correlation of each pixel in the original image. Correlation coefficients in the horizontal, vertical, and diagonal directions are included in the correlation measure. In general, the correlation of the original image’s neighboring pixels is close to one, whereas the correlation of the original image’s neighboring pixels is close to zero. Equation (15) shows its formula: where x and y are the two adjacent pixels, L is the total number of pixels in the image, is the correlation between two adjacent pixels, is the covariance of two pixels, is the standard deviation, and is the mean value. Randomly, 5000 pixels in the plaintext and ciphertext images were selected, and the distributions of these pixels in the horizontal, vertical, and diagonal directions from the R, G, and B channels were observed. Figure 13 and Figure 14 show the plaintext and ciphertext distributions of the pixel points, respectively. The correlations between the original image and the encrypted image in Figure 13 and Figure 14 show that among the 5000 randomly selected pixel pairs, the pixel pairs in each direction of the three channels of the original image are closely distributed near a diagonal line, whereas the pixel pairs of the encrypted image are scattered and essentially irrelevant. The horizontal, vertical, and diagonal correlation coefficients of three sets of color encrypted images are shown in Table 6, along with a comparison to other techniques. It can be seen from the data that the correlations of the pixel pairs of the ciphertext image corresponding to the algorithm in this study are less than 0.01 in the horizontal direction, vertical direction, and diagonal direction. This shows that the correlation between each pixel of the ciphertext is very low, which can effectively resist statistical attacks. Compared with the other algorithms, it can be found that the correlations of the pixel pairs of the Lena ciphertext image corresponding to the algorithm in this study are generally smaller than those of other literature, indicating that the statistical characteristics of the ciphertext image are lower, which proves that the algorithm has a stronger ability to resist statistical attacks.

Entropy is generally used to describe the complexity of things, and entropy is a measure of the random degree of information. The ideal value of entropy for a color image with a pixel value domain of [0, 255] is 8. The closer the entropy value is to 8, the higher the average uncertainty and complexity of the signal, and the better the encryption algorithm. The calculation formula of information entropy is shown in Equation (16): where, is the gray value, and is the probability of gray level appearing. Table 7 lists the entropy values of the three channels of the Lena, Peppers, and Baboon original images and encrypted images, respectively, and uses the Lena color image to compare with other algorithms. From Table 7, we can see that the entropy values of the three channels of the ciphered image are above 7.9992, which is close to the ideal value of 8. This indicates that ciphertext image encrypted by this algorithm has high complexity and high uncertainty.

The encrypted image will invariably be damaged by noise pollution or information loss during Internet transmission, making it difficult to decipher the decrypted image. As a result, an encryption algorithm must be resilient and able to withstand noise pollution and the loss of some information in real life. To demonstrate the robustness of the algorithm, noise attack and cropping attack were carried out on the Lena color ciphertext image before decryption.

Salt and pepper noise was added to the Lena encryption image, with densities of 0.001, 0.01, and 0.1. Figure 15 depicts the decryption impact of the encrypted image after noise addition. Figure 15 shows that the quality of the decrypted image degrades as the density of the salt and pepper noise increases. When the density of the salt and pepper noise is 0.001, there are only a few dispersed noise points in the decrypted image. However, when the density is 0.1, there are many noise points in the decrypted image, affecting the image’s information reading. The most popular and extensively used objective metric of image quality is PSNR, with higher values signifying greater image quality. When the PSNR value is greater than 40 dB, the image quality is exceptional; when it is 30–40 dB, the image quality is good; when it is 20–30 dB, the image quality is bad but acceptable; and when it is less than 20 dB, the image quality is undesirable. The following is how PSNR is defined: where MSE represents the mean square error of the current image p and the reference image D, M and N are the height and width of the image, respectively, and n is the number of pixels in bits. Equation (17) was used to test the decryption diagram of salt and pepper noise added to different degrees, and the test results are shown in Table 8: Table 8 shows that when the salt and pepper noise level is 0.00001, the PSNR of the three channels is better than 50 dB, indicating that the decrypted image quality is excellent at this moment. When the salt and pepper noise density is 0.0001, and the PSNR of the three channels is larger than 40 dB, the decrypted image quality is good at this moment. The PSNR of the three channels is greater than 30 dB when the salt and pepper noise density is 0.001, indicating that the decrypted image quality is average at this time. The PSNR of the three channels is larger than 20 dB when the salt and pepper noise density is 0.01, indicating that the decrypted image quality is bad at this time. The anti-noise ability of the algorithm is acceptable when the salt and pepper noise density is less than 0.01.

Gaussian noise with a mean of 0 and variances of 0.001, 0.005, and 0.01 was added to the Lena encrypted image. Table 9 shows the PSNR values of each channel after decryption. Figure 16 shows the decrypted image. The results show that the decrypted image can still be recognized under a certain degree of noise attack.

In order to show the decryption ability of the algorithm for flossy images, this study trimmed the upper left corner and the center of the encrypted image, and the sizes were , , , and , in order. As illustrated in Figure 17, the varied crop placements and crop sizes had an effect on the degree of decryption restoration. The worse the image reproduction, the higher the crop size. Even though the ciphered image loses a quarter of its image information, the broad outline of the original image may be reconstructed, indicating that the approach is resistant to cropping attacks.

In addition to security considerations, algorithm efficiency is also an important aspect of a good encryption algorithm. Time complexity is a measure of efficiency. Compared with classical DNA coding, the improved DNA coding proposed in this study uses an alternative process, and the increased time complexity mainly includes the generation of lookup tables and indexes on lookup tables. Assuming that the image size is , the time complexity of generating the lookup table is O(4 mn), and the time complexity required for indexes is O(mn). In the diffusion stage, the classical diffusion algorithm needs to transform the image into a one-dimensional sequence for forward and reverse diffusion, so the time complexity of the color image is O(6 mn). In this research, a three-dimensional and six-way algorithm was adopted. Under the premise of parallel operation, only O(2 m + 2 n + 4) times are needed, which improves the diffusion efficiency.

Through research on image encryption algorithms, it was found that there are some defects in the DNA code encryption algorithm and the traditional one-dimensional diffusion image encryption algorithm. To address the problem that the DNA coding algorithm is weak in resisting exhaustive attacks and prone to safety hazards due to its fixed base complementary pairing criteria and base operation criteria, this study proposed an improved DNA coding method, using a lookup table to perform base substitutions. In this method, the chaotic sequence was used as the seed of the pseudo-random sequence generator to regenerate the random sequence and encode it into a lookup table. At the same time, the plaintext pixel values were encoded as the row and column coordinates of the lookup table, and the base pairs stored in the lookup table were obtained through the index to replace the plaintext pixel values. This base replacement method, which is based on the chaotic system to generate pseudo-random sequences twice and form a lookup table, improves the complexity and randomness of the algorithm through the interspersed use of various encoding methods, thereby enhancing the security performance of the algorithm. To address the problem that the traditional one-dimensional diffusion algorithm is not efficient when encrypting images with a large amount of data, a three-dimensional scrambling diffusion algorithm was proposed, which takes the matrix, row, and column as the diffusion unit successively, and improves the diffusion efficiency through the parallel operation. To sum up, it is of great value to study the image encryption algorithm based on DNA encoding; the improved DNA-encoding and three-dimensional six-direction diffusion algorithm of this algorithm can be realized through parallel computing, which can improve security performance and improve operating efficiency at the same time. Especially for the use of hardware such as FPGA to process large color images, this research has great significance.