Hybrid Encryption Algorithm Based on Gray Curve and Josephus Permutation

This paper proposes a new image encryption algorithm based on chaos map systems, hash algorithm, and Josephus permutation. The algorithm consists of chaos initialization, pixel position permutation, and pixel information diffusion. The algorithm's initialization is generated by the original image, which has a high sensitivity to the initial value. The permutation step length is composed of Josephus permutation and gray curve permutation, which completely disturbs the pixel distribution. The diffusion process is composed of cross operation and ciphertext feedback, which breaks the strong correlation between pixels. The simulation results of the encryption algorithm are used to analyze its information entropy, the correlation between elements, and other indicators. The ciphertext image is attacked in several ways, and we analyzed its defense ability. Simulation results show that the algorithm can effectively encrypt image information and has a good defense against various attacks.


Introduction
In recent times, with the rapid development of science and technology, information and data security play an increasingly important role. To protect the important information of private, enterprise, and government, how to improve the security performance of image transmission is an urgent problem to be solved. To ensure the integrity and security of information, many encryption algorithms are used to protect the security of network information, such as DES [1] and AES [2]. Shannon [3] laid a solid foundation for cryptography and encryption systems and put forward the famous encryption system theory, and many encryption algorithms came into being. Mishra and Mankar [4] proposes a text encryption algorithm using pseudorandom number generator and nonlinear function. Babaei [5] proposes an encryption algorithm based on DNA computing, which can realize parallel encryption of a large number of data. L. D. Singh and K. M. Singh [6] proposes a new encryption algorithm based on elliptic curve cryptography, which provides higher security performance with smaller key lengths and reduces the high cost of the map operation.
Because the image information has the characteristics of a strong correlation between adjacent elements, when the image information is transmitted, the existing encryption algorithm is unable to meet the increasing demand for encryption performance.
erefore, an algorithm with stronger encryption performance is needed to encrypt and protect the image information. With the development of chaos theory, more and more scholars turn their attention to the encryption algorithm based on the chaos system. e encryption algorithm based on chaotic is more suitable for image encryption because of its ergodicity, high sensitivity, and pseudorandom characteristics. But it would be too simplistic to encrypt images with only chaotic sequences. Scholars began to combine the Josephus problem with chaotic sequences to encrypt images. e Josephs traversal method selects the step size by using the pseudorandom sequence generated by the chaotic system and selects the corresponding image pixels cyclically to achieve the effect of scrambling. Many encryption algorithms use Josephus traversal to realize image encryption. Xu et al. [7] proposed an image encryption scheme based on the combination of Josephus permutation and image filtering. Adjacent pixels can be quickly scattered into different rows and columns. To achieve the purpose of encrypting the image, Wang et al. [8] proposed an image encryption scheme based on Josephus traversal and mixed chaotic maps. e image is encrypted by scrambling the pixel position using Josephus traversal and then using the position to randomly change the pixel value. Hua et al. [9] proposed an image encryption algorithm utilizing the principles of the Josephus problem and the filtering technology. e chaotic sequence can also be used to scramble the bit-level of the pixel. Gan et al. [10] introduces a novel chaos-based image encryption algorithm for color images based on three-dimensional (3-D) bit plane permutation. Wu et al. [11] proposed a new color image encryption algorithm combined with rectangular transformation. e algorithm can encrypt three primary color channels of the image at the same time.
With the continuous improvement of computing power and information security requirements under the Internet background, image encryption algorithm needs to have a more complex structure and higher sensitivity to be more difficult to crack. e break of the MD5 function [12] and the update of computer hardware are more and more threatening to the encryption system. Image encryption technology can be roughly divided into two categories at present: compressed image encryption technology and spatial image encryption technology. e use of compressed sensing technology to encrypt images has developed rapidly. e image is encrypted and compressed at the same time, and then embedded into the carrier image to achieve the purpose of encrypting the image. Hua et al. [13] proposed a visually secure image encryption method based on adaptive threshold sparsification and parallel compressed sensing. e algorithm can greatly improve the quality of reconstructed images and has higher encryption efficiency and security. e spatial image encryption technology is used to encrypt the uncompressed image.
at is, the image is operated as a two-dimensional matrix. Spatial image encryption technology is divided into two types: symmetric encryption and asymmetric encryption. At present, the most commonly used encryption method is the "obfuscationdiffusion" structure, which is also a symmetric key encryption scheme. A chaotic system with a weak structure is more vulnerable to attack and break, resulting in information loss and leakage. e two-dimensional chaotic system has more parameters, a more complex structure, better ergodicity, sensitivity, and other characteristics. So the encryption algorithm based on two-dimensional chaotic system usually has a large key space and strong security performance. Hua et al. [14] proposed a color image encryption scheme based on the combination of orthogonal Latin squares and a new 2D chaotic system. First, the pixels of the two-dimensional matrix are scrambled by using Latin squares, and then the pixel-level diffusion is performed on the scrambled image. is method can effectively solve the relationship between color images and Latin squares. Chai et al. [15] presents a color image cryptosystem based on dynamic DNA encryption and chaos. Based on the logistic map, Jin et al. [16] proposed an encryption algorithm, which combines the pre-encrypted image with the original gray value in disorder. Tong and Liu [17] proposed an encryption algorithm based on high-dimensional dynamic multiple chaotic maps, which combined with cyclic displacement to produce a faster avalanche effect and excellent encryption effect. Som et al. [18] proposed a symmetric key encryption algorithm for color images based on chaotic map and pseudorandom binary number generator (PRBNG), which has a very large key space to improve the security of the encryption system. Hua et al. [19] proposed an image encryption scheme for the S-box of complete Latin squares. S-box is the nonlinear part of a symmetric key encryption scheme. It directly determines the performance and security level of the encryption scheme. is paper applies S-box to image encryption applications.
e result of the analysis shows that it has high security and can effectively resist differential attacks, antilinear attacks, and other attacks. Zhang and Wang [20] proposed a new spatiotemporal chaotic image encryption algorithm based on the hybrid linear-nonlinear coupled chaotic map. e bit-level pixel arrangement strategy makes the low-bit plane and the higher-bit plane of the pixel displace each other without any additional storage space, greatly improving the calculation speed and reducing the calculation cost. Norouzi et al. [21] proposed an encryption algorithm based on a hyperchaos system, which combines the masking method and bit plane diffusion, and achieves high security of the encryption system.
To further enhance the chaotic characteristics of the encryption algorithm and enhance the defense ability against the attack, a variety of coupled chaotic maps have a better prospect. is paper proposes an efficient encryption scheme for image data. e algorithm is based on the pseudorandom sequence generated by PWLCM map and 2D-LSCM map, combined with gray curve scrambling, Josephus traversal, and other encryption methods, to achieve effective encryption and protection of image data. e second section of this paper introduces the theoretical basis of generating pseudorandom sequences and encryption methods in the proposed algorithm. e third section introduces the specific calculation steps to realize image encryption. e fourth section analyzes the security of various data and the ability to resist various attacks on the experimental simulation results, and the results show that the algorithm has fast calculation, strong security, and good defensive performance. erefore, the encryption system can be used for digital image encryption.

Piecewise Linear Map.
In the algorithm proposed in this paper, we use piecewise linear map to generate pseudorandom sequences needed by Josephus traversal. Piecewise linear map is PWLCM [22] for short, and its definition is shown in the following formula: Computational Intelligence and Neuroscience where F(x i−1 , τ) is PWLCM map, x ∈ [0, 1), and control parameter τ ∈ (0, 0.5). e chaotic system can enter a stable chaotic state and the control parameter τ is a part of the key. e simulation diagram of the PWLCM chaotic system is shown in Figure 1 and the Lyapunov exponential diagram is shown in Figure 2. It can be seen that the PWLCM chaotic system has good pseudorandomness and ergodicity. PWLCM chaotic system is a one-dimensional chaotic system. Although its structure is relatively simple, its time and space complexity is relatively small. When generating pseudorandom sequences in the proposed encryption system, it can provide high efficiency and save calculation costs. We choose the sequence generated by the PWLCM system as the step length of the Josephus traversal. e ergodicity and robustness of the PWLCM system are enough to meet the requirements of Josephus traversal.

2D-LSCM Map.
e two-dimensional logistic sine coupled map (2D-LSCM) is a coupling of one-dimensional logistic map [23,24] and sine map [25]. e definition of logistic map is shown in the following formula: e control parameter c ∈ (0, 1). e definition of sine map is shown in the following formula: e control parameter μ ∈ (0, 1). e bifurcation and simulation diagrams of logistic map and sine map are shown in Figures 1 and 2. It can be concluded that the security of the encryption algorithm is not high due to the lack of ergodicity and other reasons when using logistic map or sine map for the encryption system alone [26]. erefore, to obtain the pseudorandom sequence, which is more suitable for the encryption algorithm, Hua coupled the logistic map and the sine map to get a new chaotic map, which is called 2D-LSCM map [27]. It is defined as follows: e control parameter σ ∈ (0, 1). e simulation diagram of 2D-LSCM map is shown in Figure 1. In Figure 1, the lines of different colors represent the motion tracks of different variables. e coupled two-dimensional chaotic map significantly improves the characteristics of chaotic system, which has strong ergodicity and sensitivity, and can provide greater key space and higher security for the encryption algorithm. Figure 2 shows the Lyapunov exponential diagram of the 2D-LSCM map. A positive Lyapunov exponent means the map is chaotic and a larger LE means better chaotic behaviors [28,29]. Besides, the diagram shows the 2D-LSCM map has more than one positive LEs, which has extremely good chaotic behavior. erefore, 2D-LSCM map has a wider chaotic range and more complex chaotic behavior.

Gray Curve.
Fractal geometry is an assumption proposed by Mandelbrot, which is based on many natural phenomena with self-similarity and high repetition. Fractal geometry is different from Euclidean geometry. It is irregular, but it has a scale structure. e fractal structure can be observed on every scale. Fractal geometry has the characteristics of self-similarity, highly complex structure, high repeatability, and iteration. General fractal sets include Mandelbrot set, Julia set, Koch curve, Cantor set, and Sierpinski set. Fractal images can be used in the permutation operation of image encryption [30,31] and get a better confusion effect. e gray curve is generated by the evolution of gray code proposed by Baudot. Because only one of its adjacent bits changes, the logic confusion caused by the change between two states is greatly reduced. e pulse interference generated in the digital circuit is avoided and the error generation is minimized during the digital-toanalog conversion. e gray curve is one of the fractal sets, and its representation is shown in Figure 3. e gray curve evolved from gray code, and its iteration rules are shown in Table 1. Firstly, a set of one-dimensional gray codes with values of 0 and 1 is generated. en twodimensional gray codes are generated based on one-dimensional gray codes, whose values are 00, 01, 11, and 10. at is to say, when generating the (n + 1)-dimensional sequence, the first 2 n elements are all elements of the n th dimension sequence in order, and the prefix 0 is added; the next 2 n elements are all elements of the n th dimensional sequence in reverse order, and the prefix 1 is added. Using computer simulation to generate gray code, which can be obtained in the following ways: keeping the highest bit of the natural binary number to be converted and taking it as the highest bit of gray code; performing exclusive OR operation on the highest bit and the secondary high bit of binary code and taking the result as the secondary high bit of gray code; calculating the remaining bits in the same way. Set the binary number to be converted to X n X n−1 X n−2 , . . . , X 1 and the code is Y n Y n−1 Y n−2 , . . . , Y 1 by using the formula (5) to convert where i � 1, 2, . . . , n − 1 and XOR is exclusive or operation. After getting the n-dimensional gray code, we can get the gray curve based on the code: convert the X coordinates and Y coordinates of image pixels into binary values corresponding to their coordinate values, and calculate their corresponding gray codes; cross the coding of the X coordinates and the Y coordinates and calculate the gray code based on the new coding, and then connect the pixel positions of these coding from small to large. en we get the corresponding gray curve.
Computational Intelligence and Neuroscience e function of the gray curve in the encryption system is to take out the pixels of different positions through gray coding transformation to disorder the gray value distribution. e gray permutation effect of the 8 * 8 image is shown in Figure 4. According to the direction of the curve, the pixels are taken out and arranged in order, and then recombined into a matrix.

Encryption Scheme
3.1. Chaos Initialization. To make the system highly sensitive to the key and the initial image, the control parameters of the chaotic system are calculated by using the variable q i related to the gray value of the plaintext image pixels. Suppose that the gray value of the plaintext image pixel is P i,j , where i ∈ (0, M), j ∈ (0, N), the control parameters σ and τ of the chaos map are calculated according to the following formula: where M, N is the image specification, P i,j is the gray value of the corresponding position of the pixel matrix, q 1 , q 2 , q 3 , and q 4 is the intermediate calculation variable, τ is the control parameter of the piecewise linear map, and σ is the control parameter of the logistic sine map. Formula (6) uses the trigonometric function twice to make the control parameter in the required range of the positive Lyapunov exponent. e encryption system initializes the sequence value with the initial image. When the initial image has a small change, the encryption result of the encryption system will change greatly. erefore, the initial chaotic system is sensitive to the initial image. e initial value of the chaotic system is generated by the hash algorithm. Take the original image P as the input. e hash sequence H with a length of 384 bits is obtained through the calculation of the SHA-384 algorithm. en take the first 64 bits of the sequence H as the value H 1 , and calculate c 1 according to formula (7). Take c 1 as the initial value of PWLCM map. Take the 65th to 128th bits of the sequence H as the value H 2 , and the 129th to 192nd bits are taken as the value H 3 . e values c 2 and c 3 are calculated according to formula (7) and are taken as the initial values of the 2D-LSCM system.
where c 0 i is the given value, i � 1, 2, and 3. e initial value of the chaotic system is determined by the original image and the given value, so it has a large key space and high sensitivity to the original image, which can effectively resist attacks.
is article uses the hash value of the plaintext image as part of the key, and we need to assign the key to other users. We can distribute it to other users through decentralized key distribution, centralized key distribution, etc. Decentralized key distribution allows each user to be assigned a session key in a secure manner. In centralized key distribution, a key center is used to exchange session keys with users.

Permutation Encryption.
Josephus permutation is an algorithm derived from an ancient allusion [32]. In the war against the Roman army, Josephus fled to a hiding place with a friend and 39 Jews after Jotapat was captured by Rome.
ese Jews would rather die than be captured. ey agreed to commit suicide by way of reporting in turn. All of them were in a circle, starting from the first reporter. Every time they reported to the third person, the one had to commit suicide. And then the next one counts again until everyone commits suicide. After the Josephus problem is transformed into a mathematical problem and simplified, it can be described as a circle of several elements. Each element is checked and counted from the beginning to the end, and the kth element is taken out. en count from the next element adjacent to the extracted element again, and loop through the above operations until the last element is removed. According to the order of being taken out, the elements are arranged in order, and we get the expected sequence of the Josephus permutation result. We perform Josephus permutation according to to the formula below: where x is the length of the element sequence involved in permutation and k is the sequence number of "suicide" specified in advance, which is the step length, and i is the order of operation. In the proposed encryption algorithm, the first number of sequence Y is used as the fixed step length to permute the first-row elements of the image matrix; the second number of sequence Y is used as the fixed step length to permute the second-row elements of the image matrix. According to this rule, the row elements of image matrix are permuted by Josephus traversal for M times. Next, Josephus permutation is operated in the first column of the image matrix with the (M + 1)-th number of sequence Y as the fixed step length; then permute the second column of the image matrix with the (M + 2)-th number of sequence Y as the fixed step length until permuting all columns of image matrix for N times. e Josephus permutation example with a step length of 7 for the element sequence with a length of 8 is shown in Figure 5, in which the element marked in cyan is the starting position of the next count.
In the simulation of image permutation, we find that if we use Josephus traversal with variable step length, the encryption system has weak resistance to data loss attack and noise attack. Although, when only a few pixels are changed, the decryption system will not be able to decrypt the original image correctly, and the decrypted image is noisy. If Josephus permutation with fixed step length is used, the elements in a certain gray value range will not be fully permuted. Using gray curve permutation as a supplement to Josephus permutation with fixed step length solves this problem well, and the problem of low key space of gray curve permutation is also solved. erefore, we use these two schemes to fully confuse the location of each pixel, and the system has a strong ability to resist noise and data loss attacks. [33] is an operation to make adjacent elements in the image influence and confuse their gray values to enhance the diffusion effect of the algorithm. In a single calculation, generally, the elements in the first place will affect the elements in the second place, and the XOR ciphertext feedback process will be repeated and operated in a different order many times to ensure that all elements experience XOR ciphertext feedback as much as possible, so that the encryption scheme can achieve a better diffusion effect. e process of XOR ciphertext feedback is as follows: firstly, the image matrix to be encrypted is expanded into a sequence with a length of M * N, and the M * N elements in the pseudorandom sequence Z generated by the chaotic system are operated by bit plane according to their positions, and then each element and the next adjacent element are calculated by bit XOR according to formula (9) from the beginning to the end.

Diffusion Encryption
where 2 ≤ i ≤ M * N, M * N is the specification of the image to be encrypted, I(i) is the value of each element of the one- Computational Intelligence and Neuroscience dimensional sequence of the image to be encrypted, and B(i) is the value of each element of the obtained one-dimensional sequence of ciphertext. Figure 6 shows a flow example of XOR ciphertext feedback. In this encryption step, the gray values of image pixels are confused with each other and the pseudorandom sequences generated by the chaotic system. e encrypted image matrix is obtained by recombining the one-dimensional sequence obtained by XOR ciphertext feedback into M * N matrix. XOR ciphertext feedback not only confuses the noise information carried by the key with the original image, but also spreads the gray values of different pixels in the image, so it is difficult for attackers to obtain information from the encrypted image.

Bit Crossover.
e crossover operation is a kind of genetic algorithm, which aims to generate new offspring by rearranging the "genetic information" of two parents according to certain new rules [34]. When this idea is applied to image encryption, it will produce the effect of confusion on the bit plane. In this algorithm, the number in the pseudorandom sequence obtained by the 2D-LSCM algorithm is used as the crossover operator after the modulo operation of 256, and the number in the encrypted image matrix is diffused under the crossover operation. e gray value of every two-parent pixel and the crossover operator are represented by an 8-bit binary number, then the value of each pair of parent bits determines the switching position or remains unchanged according to the value of the crossover operator. If the value of a bit of the crossover operator is 0, the value of the corresponding bit of the parents is exchanged, and the new individual inherits the bit values of different positions, respectively. If the value is 1, the value of the corresponding bit of the parent remains the same, and the child inherits the bit values of the same position. Table 2 shows the algorithm principle of generating new elements through bit recombination and diffusion. For example, suppose that the two parents A and B participating in the crossover operation are 10111010 and 01000101, respectively, and the crossover operator is 10010110. e crossover results of A′ and B ′ is shown in the table.

Computational Intelligence and Neuroscience
N th pairs of elements in the first and second rows are diffused. e crossover operators are X 1 , X 2 , X 3 , . . ., X N ; use the (N + 1) th to (2N) th number in the sequence X as the crossover operator to perform the crossover operation on the first to N th elements of the second and third row, and the crossover operators are X N+1 , X N+2 , X N+3 , . . ., X 2N ; and so on, until the M row of the image matrix is diffused, the crossover operator is e encryption rules for the cross-operation of the 4 * 4 matrix are shown in Figure 7. en the image matrix is operated by columns according to the same rules.
rough the crossover operation, the gray value of each pixel is confused and affects the adjacent elements, and then it spreads to the gray value of all other elements of the image through a continuous iterative operation.

Encryption Process.
Due to the high correlation or noise between pixels of image data, a good image encryption system should be able to overcome these shortcomings when it is attacked by data loss attack, statistical attack, etc. Based on the pseudorandom sequence generated by 2D-LSCM, the encryption algorithm proposed in this paper confuses the image pixel position by gray curve and Josephus permutation operations; and carries out crossover operation and exclusive or ciphertext feedback operations for gray value information of each pixel. e specific flow chart of the encryption algorithm proposed in this paper is shown in Figure 8. e chaos is initialized as described in 3.1. e control parameters and initial values of the encryption system are generated according to the initial image. e initial values are input into PWLCM map and 2D-LSCM map respectively, and the pseudorandom sequences SX, SY, and SZ are obtained. e three sets of sequences were amplified and modeled according to formula 10 to obtain sequences X, Y, and Z. e block processing method is shown in Figure 9.
(2) e gray curves permutation of the pixels in the matrices K 1 , K 2 , K 3 , and K 4 is operated, respectively, as described in Section 2.3. (3) Reassemble the scrambled four block matrices in the upper left corner, the upper right corner, the lower left corner, and the lower right corner to obtain the reconstructed image matrix P 1 . Take out the first (M − 1) * N elements in the X sequence and take them as the crossover operator, and carry out bit crossover operation on the elements in the image matrix P 1 as described in Section 3.3.2 and obtain the image matrix P 2 . (4) Take out the M * N pseudorandom values in the sequence Y, and carry out bit exclusive or with the element pixel values in matrix P 2 and convert the obtained matrix into a sequence and diffuse the elements by bitwise exclusive or from the beginning to the end. Repeat it twice in positive and reverse order, and then restore the sequence to the M * N matrix to get matrix P 3 . (5) Take out M + N pseudorandom values in sequence Z, and use them as the step length of Josephus permutation. Josephus permutation operation is performed on image matrix P 3 as described in Section 3.2 to obtain the final encrypted image matrix P 4 . e decryption algorithm is the inverse operation of the encryption algorithm, which will not be discussed here.

Simulation Result and Security Analysis
Detecting the security performance of an image encryption algorithm is the standard to evaluate its feasibility. e analysis indexes of the encryption system are key space, histogram analysis, information entropy analysis, NPCR,     Figure 10. It can be seen that the algorithm can effectively encrypt the original image, and the decrypted image has no loss and will not destroy the original information contained in the file to be encrypted. Next, we test each index of the encryption algorithm.

Keyspace.
Of all the attacks against encrypted information, the brutal attack is the most common and simple way. e attacker attempts to crack the password text image by trying each key one by one. erefore, as long as the key space of the encryption algorithm is large enough, it can effectively resist the brutal attack. In this algorithm, the key includes the initial values of piecewise linear map, SHA-384, and 2D-LSCM, and its key space is about 2 442 . erefore, the key space of the algorithm is large enough. It is difficult to find the initial key used by the encrypting step and by the brutal attack using the existing computer, so it can effectively resist the brutal attack.

Key Sensitivity Analysis.
In response to hacker attacks, a good initial key sensitivity can make the encryption system more resistant. In the case of keeping other parameters unchanged, changing a certain key to a very small value, then try to decrypt and simulate the results, and we can get the key sensitivity analysis of the encryption system. is analysis changes the key c 0 i to (c 0 i + ∆K) and (c 0 i + ∆K). To quantitatively analyze the key sensitivity, the ciphertext difference rate (CDR) analysis is performed on the encrypted images before and after the key change according to formula 11. Figure 11 shows the results of decryption using the changed key, and Table 3 shows the CDR results. It shows that a small change in the key can cause the decrypted image to be different from the original image [35].
Diff p (A(i, j), B(i, j)), where Y represents the original decrypted image, and Y 1 and Y 2 represent two decrypted images encrypted with a slightly changed key. e I represents the original image, K represents a key, and C represents the encryption algorithm.

Histogram Analysis.
How many pixels appear in each gray value of the histogram can get very intuitive data, which directly reflects whether the distribution of image matrix elements is uniform or not. In the encryption algorithm, it is generally believed that the more average the encrypted result is, the noisier the distribution is, and the better the   Computational Intelligence and Neuroscience encryption effect is. Figure 12 shows the histogram data comparison between the encrypted images and the original images in the simulation results of the proposed algorithm. From the histogram analysis, we can see that the pixel distribution of the original image has been effectively disrupted. e correlation between each pixel has also been    broken, and its pixel distribution has achieved a very uniform and smooth effect. e uniformity of the histogram is evaluated by the chisquare test by formula (12). Table 4 shows the chi-square test results of the three groups of decrypted images of size 256 * 256. It can be seen that the proposed encryption  algorithm accepts the null hypothesis, and the p-value of the password images is greater than 0.05, indicating the consistency of the histogram samples. erefore, it can be concluded that the proposed encryption algorithm can effectively resist statistical attacks [36].
where P(i) is the pixel value and T(i) is the theoretical value.

Correlation Analysis of Adjacent Elements.
e correlation of adjacent elements of the encrypted image should be as small as possible, including horizontal correlation, vertical correlation, and diagonal correlation. When the correlation properties of adjacent elements are completely broken, it is difficult for attackers to break the ciphertext image through statistical analysis. We perform correlation analysis on Lena image of size 256 * 256. e calculation of the correlation of adjacent elements [37] is shown in formula 13. Table 5 shows the correlation calculation results of adjacent elements in all directions of the original image and the encrypted image.
x and y represent the gray values of two adjacent pixels in the image. We randomly selected 2500 pairs of pixels from all directions and compared them with the correlation of adjacent pixels in references [38][39][40][41].
e correlation between pixels in the calculation results is as follows: It can be seen from Table 5 that the encryption scheme breaks the correlation between adjacent pixels very well, and the encryption effect is better than that of these reference algorithm performances. erefore, the encryption effect is very good and can effectively resist attacks.

Information Entropy and Local Entropy.
Information entropy is an important index to measure the encryption effect of the encryption algorithm. e ideal value of information entropy of a good encryption algorithm should be close to 8. e calculation process of information entropy is shown in the following formula: where P(x i ) represents the probability of occurrence of gray value x i . If the entropy of the encrypted result is close to 8, the encryption effect of the system is effective. e local information entropy measures the randomness of an image by calculating the average value of the information entropy over multiple nonoverlapping and randomly selected image blocks as a measure to describe the randomness of the test image [42]. We calculate the local information entropy of the image by the formula as follows: where T B is a randomly selected pixel and k is the number of randomly selected nonoverlapping image blocks with T B pixels.
Global and local analysis of information entropy on Lena ciphertext image of size 256 * 256. Table 6 shows the information entropy and the local information entropy of the ciphertext image obtained by the proposed encryption algorithm and compared with other algorithms. It can be seen from Table 6 that the information entropy of the ciphertext image obtained by the proposed encryption scheme is close to 8. Although the local information entropy is significantly lower than the global information entropy, it is still close to 8. erefore, the encryption scheme has a good ability against statistical analysis attack. 4.6. Differential Attack Analysis. NPCR and UACI are important indexes to evaluate the security of encryption algorithms when resisting differential attacks. e most point to resist differential attack is to compare the difference between two encrypted images. NPCR refers to the change rate of the number of pixels and UACI refers to the uniform average change intensity. e calculation process of the above two indexes is shown in formula (16). To measure the performance of the proposed encryption algorithm from a more secure perspective, Wu et al. proposed a comprehensive study of randomness tests including NPCR and UACI, and they focused on the theoretical critical NPCR and UACI values for encrypted images of different sizes. Tables 7  and 8 show the NPCR and UACI values for the three α-level  [38] 0.0090 0.0079 0.0032 Reference [39] 0.0011 0.0005 0.0016 Reference [40] 0.0008 -0.0019 -0.0016 hypothesis test scores for three different-size images, respectively [43].
Analyzing the sensitivity of the image encryption algorithm is analyzed by changing one pixel in Lena image of size 256 * 256. Table 9 shows the simulation results and compares them with other algorithms.
where M and N are the specifications of the image, P 1 is the plaintext image, and P 2 is the ciphertext image. e ideal value of NPCR and UACI should be 100% and 33%, respectively [43]. e results given in Table 9 all satisfy the three α-significance level tests of NPCR and UACI, indicating that the encrypted images generated by the proposed encryption algorithm are very different from the original images. erefore, it can be considered that its encryption effect has good performance against differential attack.

Data Loss Attack Analysis
. A good encryption system should be able to recover the plaintext image as much as possible when it is attacked and lose data. Even if the ciphertext image loses part of the data when being attacked, the decrypted image obtained through the system should be able to express the main information of the original image. Data loss attack analysis means that in the simulation experiment, the pixels in a certain area of the encrypted image are destroyed artificially, then they are used as the input of the decrypted image for operation. en the recovery degree of the decrypted image is analyzed and compared with the original image. We cut out    [38] 99.6634 33.7112 Reference [39] 99.9950 34.1222 Reference [40] 99.6109 33.4783 Reference [41] 99.6100 33.3800  Figure 13. e correlation between the adjacent pixels in the decrypted image and the original image can be used as the quantitative analysis of the results, which are shown in Table 10. e calculation of the correlation of adjacent pixels is shown in formula (13). e peak signal-to-noise ratio (PSNR) can be used to measure the decryption recovery ability of the encrypted image [44,45]. e calculation of PSNR is shown in formula (17), and the results are shown in Table 11. rough comparison, the algorithm can recover the information features of the original image effectively. erefore, the proposed encryption system has excellent ability against data loss attack.
PSNR � 10 * log 255 2 MSE (dB), where I P and I C are the plaintext image and ciphertext image, respectively.

Noise Attack Analysis.
Image information in the transmission channel is usually subject to a variety of interference, such as pulse interference, resulting in some light and dark impurities in the ciphertext image matrix, which is called noise. e appearance of noise will destroy the original data in the image information, resulting in a certain degree of loss of the decrypted image information calculated by the receiver. We discuss the attack effect of salt and pepper noise on the encryption system. e attack ratio of pepper and salt noise represents the attack intensity of external interference on the image data, that is, the number of pepper and salt noise point replacement in every 100-pixel point. After adding salt and pepper noise with a certain attack intensity, the encrypted image is calculated by the decryption system, and the decrypted image is compared with the original image. e correlation of adjacent pixels is used as the reference index for quantitative analysis. Figure 14 shows the simulation results of noise attack on Lena ciphertext image of size 256 * 256. e correlation analysis of the adjacent pixels of the decrypted image is shown in Table 12. e PSNR results are shown in formula (17), and the results are shown in Table 11. It can be concluded that the encryption algorithm still retains a good ability against salt and pepper noise attacks.

NIST Test.
We use pseudorandom sequences in the image encryption algorithm proposed in this paper. e randomness of the pseudorandom sequence will affect the security of the encryption system. So we need to test the randomness of the pseudorandom number sequences generated by the two chaotic systems. In this paper, we use the NIST test to examine the randomness of pseudorandom sequences. If the NIST test result p ∈ [0.01, 1], the sequence is random. e results are shown in Table 13. We can see that both the PWLCM system and the 2D-LSCM system passed all randomness tests.

Time Complexity Analysis.
e time complexity of the encryption algorithm determines its calculation cost [46,47]. A good encryption system should have a faster encryption speed. e number of running time required for the operation by a computer program can be expressed as a function f(n) whose independent variable is the input size n. Time complexity is the index used to estimate the operation time of the program. e time complexity of an algorithm is usually measured by f(n), which is called O(f(n)). e number of operations ignores the constant value and the coefficient of the highest power. Assuming that the number of pixels of the image to be encrypted is the input size n, the time complexity of the algorithm proposed in this paper is O(n 2 ). erefore, the algorithm has high efficiency and can realize image encryption quickly, which can be applied to practical applications.   e cracker uses the assumed plaintext (ciphertext) to calculate the corresponding ciphertext (plaintext) through the encryption system, then obtains the encryption key by analyzing its characteristics, and finally cracks the original image, which is called the chosen plaintext (ciphertext) attack. In this attack simulation, the existing permutation-based encryption algorithm is easy to crack [48]. e attacker usually selects a pepper noise image with the same specification as the attacked image to obtain the intermediate key of the encryption algorithm. en select a unique image that represents the position of a pixel to track this pixel, so as to obtain its position in the initial image, and finally achieve the purpose of cracking the entire initial image.
e encryption algorithm proposed in this paper has a strong defense against the chosen plaintext (ciphertext) attack. In the process of chaos initialization, the control parameters and initial values of the selected chaotic system are generated by the initial image, so the sensitivity is high enough. When the cracker attacks, because all the gray pixel values of the pepper noise image are 0, the chaotic sequence generated according to this algorithm will change greatly with the change of the original image. is kind of attack cannot track the change of any pixel position to crack the original image. Even if the cracker chooses the special image attack of non-noise, as long as the cracker cannot get the accurate initial value, he cannot get the chaotic sequence which is fed back and confused with the plaintext image. e attacker cannot track the transfer of the pixel position by assuming the image. erefore, the encryption algorithm proposed in this paper can effectively resist the chosen plaintext (ciphertext) attack and ensure the security of important information.

Conclusion
In this paper, we propose an image encryption algorithm based on two-dimensional chaotic system and Josephus permutation. In this algorithm, the distribution of the pixel matrix is disturbed by Josephus traversal and gray curve to   permute the pixel position. e binary value of the pixel is diffused by crossover operation and the ciphertext feedback, which breaks the strong correlation of image data. Experimental and simulation results show that the proposed encryption scheme has a large key space, high sensitivity to the encrypted image and the initial key, and the encryption results are good enough in various analysis indicators and have good defense ability against various attacks. erefore, it can be considered that the proposed encryption scheme is better than the existing encryption algorithm, which makes up for the shortcomings of the traditional encryption algorithm, such as complex management, and slow computing speed, and can be used for image information encryption and information security protection.

Data Availability
e data used to support the findings of this study are included within the article.

Conflicts of Interest
e authors declare that they have no conflicts of interest.