**1. Introduction**

Digital images play a critical role in the world today. Digital images make up 70% of the transmitted data via the Internet [1]. They often contain sensitive and valuable information which requires protection against unauthorised access in various applications such as military images, medical images and Satellite images. Therefore, researchers have been designing methods to protect digital images from piracy while they are transferred from one place to another such as encryption algorithms via chaos [2–6], DNA coding [7], and wavelets [8]. Also S-boxes play an excellent role in confirming the resistance of block ciphers against cryptanalysis [9]. In Reference [10], the authors presented an efficient algorithm based on a class of Mordell elliptic curves to generate S-boxes. One of the most stable and powerful public key cryptosystems has been proven to be the Elliptic Curve Cryptography, which is popular for its high performance. But improving protection by increasing the duration of the key is inefficient [11,12].

Among the many ways of image cryptography, the image cryptography based on chaotic map will selected over the past two decades. This is because the chaotic mappings have necessary proprieties such as high sensitivity to the initial conditions and the parameters, nonlinearity, non-periodicity, and pseudorandomness [13–17]. Numerous researchers have presented image cryptography algorithms via chaotic maps. Some of these algorithms have limited key space, weak keys, vulnerability to chosen plaintext/ciphertext attacks [18–20]. Almost all the authors used the permutation-substitution (confusiondiffusion) model to encrypt/decrypt the image. There are different permutation methods, from performing a shuffling to rows/columns to performing more complicated iterative processes. For example, in Reference [3], the authors proposed rows/columns shuffling

**Citation:** Karawia, A. Cryptographic Algorithm Using Newton-Raphson Method and General Bischi-Naimzadah Duopoly System. *Entropy* **2021**, *23*, 57. https://doi.org/10.3390/e23010057

Received: 7 November 2020 Accepted: 26 December 2020 Published: 31 December 2020

**Publisher's Note:** MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

**Copyright:** © 2020 by the author. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https:// creativecommons.org/licenses/by/ 4.0/).

algorithm using the logistic map to ge<sup>t</sup> permutation. Karawia in Reference [6] suggested an image encryption algorithm using Fisher-Yates shuffling to obtain permutation while Shakiba in Reference [21] performed cyclic shifts to the rows/columns via Chebyshev mapping to achieve permutation. Xiao et al. in Reference [22] used switch control mechanism to perform permutation for rows and columns of plain image. For substitution, majority of the authors applied the XOR processes [3–6,21,23], or addition modular 256 during the substitution stage of encryption [24]. There are many maps (chaotic and hyperchaotic) utilized to design encryption algorithms, for example, 1D chaotic map in Reference [25], 2D generalized Arnold map in Reference [26], 3D Cat chaotic map in Reference [27,28], and 4D chaotic map in Reference [29].

Many of the known chaotic image encryption algorithms are resistanceless for chosen plaintext attacks(CPA). These image encryption algorithms are broken by Li et al., algorithm [30], such as References [25,31,32]. To avoid this, the image encryption algorithm must be dependent on the plain image and randomized [21,33]. Based on the dimension of the chaotic map, most of 1D-chaotic maps have simple forms and simple chaotic orbits and can be guessed. So image encryption based on 1D chaotic maps are low secure [19,34]. On the contrary, the hyperchaotic maps have more complicated form and complicated chaotic performance which make expectation of their chaotic orbits is difficult [35].

In the current article, we design an image encryption algorithm that uses Newton-Raphson's method, to shuffle the rows/columns of the plain image, and the general Bischi-Naimzadah duopoly system, to diffuse the pixels of the shuffled image. The general Bischi-Naimzada is selected to solve three essential problems: (i) the randomness of the chaotic sequences, (ii) the space of the secret key, and (iii) improving the security compared with the algorithms in literature. The chaotic sequence generated from it is extremely random. Also, it has eight parameters and two initial values and thus increasing the secret key space for the image encryption algorithm. In this algorithm, the key mixing proportion factor *K* is utilized to generate the secret key [36]. So, the proposed algorithm depends on the plain image and it can provide CPA-security. For more details about chaos based image encryption techniques, see Reference [37].

The main contributions of the current article are: (i) using a 2D chaotic map (the general Bischi-Naimzadah duopoly system) with a large positive Lyapunov exponent, wide and uniform distribution, (ii) Performing rows/columns shuffle for the plain image using pseudo-random sequence generation based on Newton-Raphson's method, (iii) performing pixel diffusion to the shuffled image, and (iv) offering CPA-security for our algorithm.

This article is prepared as follows. In Section 2, the general Bischi-Naimzadah duopoly system is presented. The proposed algorithm is introduced in Section 3. In Section 4, security experimental results and comparative analyses are given. Finally, conclusions are mentioned in Section 5.

#### **2. General Bischi-Naimzadah Duopoly System (GBNDS)**

The image encryption needs a sequences of random numbers to generate a good secret image. The current paper takes advantage of the effectiveness of the general Bischi-Naimzadah duopoly system to generate pseudorandom numbers. The general Bischi-Naimzada game is a market vying between two companies based on sales constraints with the aim of maximising profits. The general Bischi-Naimzadah duopoly system is mathematically defined as [38]:

$$\begin{array}{l} q\_1(t+1) = q\_1(t) + \nu\_1 q\_1(t) \left[ (1 - \mu\_1)(a - 2bq\_1(t) - bq\_2(t)) - c\_1 \right] \\ q\_2(t+1) = q\_2(t) + \nu\_2 q\_2(t) \left[ (1 - \mu\_2)(a - 2bq\_2(t) - bq\_1(t)) - c\_2 \right] \end{array} \tag{1}$$

where

*qi*: the output of company *i* = 1, 2,

*a*> 0: constant price,

*b* > 0: the market price slope,

*ci*: the marginal cost, *i* = 1, 2, *μi* > 0: associated with the sales constraint, *i* = 1, 2,

*νi* > 0: the adjustment speed of company *i* = 1, 2.

The chaotic behavior of system (1) is observed by the values of the parameters: *a* = 11.25, *b* = 0.5, *c*1 = 0.20, *c*2 = 0.30, *μ*1 = 0.002, *μ*2 = 0.60, *ν*1 = 0.20, *ν*2 = 0.70 and initial values *q*10 = 0.10, *q*20 = 0.20. Figure 1a displays the bifurcation diagram of system (1) regarding the parameter *μ*1. Lyapunov exponent of system (1) regarding the parameter *μ*1 is shown in Figure 1b. Figure 2 displays phase diagram of system (1). It presents four unconnected chaotic areas. Whereas the phase diagram of system (1) at *μ*1 = 0.97 is given in Figure 3 and it presents a chaotic attractor. The main advantages of the proposed coding scheme compared to other systems in the literature is that the chaotic coding sequence extracted from the **GBNDS** is extremely random. This is because this it contains many chaotic regions for different values of the parameters. The proposed system also shows a grea<sup>t</sup> positive feature, which is the emergence of a very wide range of chaos and complex dynamics with the parameter *μ*1 in which the system (1) shows very complex chaotic behavior [38]. Moreover, incorporating the effects of sales constraints into the form has the advantage of increasing the number of parameters in the form and thus expanding the secret key space for the cryptography process. Also, a stable coexistence of multiple chaotic attractions is observed in this case [38].

**Figure 1.** (**left**) Bifurcation diagram of system (1) regarding *μ*1, (**right**) Lyapunov exponent of system (1) regarding *μ*1.

**Figure 2.** Phase diagram of system (1) for *a* = 11.25, *b* = 0.5, *c*1 = 0.20, *c*2 = 0.30, *μ*1 = 0.002, *μ*2 = 0.60, *ν*1 = 0.20, *ν*2 = 0.70, *q*10 = 0.10, and *q*20 = 0.20.

**Figure 3.** Phase diagram of system (1) for *a* = 11.25, *b* = 0.5, *c*1 = 0.20, *c*2 = 0.30, *μ*1 = 0.97, *μ*2 = 0.60, *ν*1 = 0.20, *ν*2 = 0.70, *q*10 = 0.10, and *q*20 = 0.20.

#### **3. The Proposed Algorithm**

The proposed method applies confusion-diffusion model to encryp<sup>t</sup> the plain image. Sequences are generated by the points, calculated by Newton-Raphson's method, on a polynomial function. Based on these sequences, the rows/columns of the plain image are shuffled (confusion phase). By applying *XOR* between the shuffled image and the generated values of the chaotic system (1), the diffusion stage modifies the pixel values. In the current section, the key generation, rows/columns Shuffling, and an image encryption/decryption algorithms are presented.

#### *3.1. The Key Generation*

Suppose that **O** = (*oij*), *i* = 1, 2, ..., *M*, and *j* = 1, 2, ..., *N*, is the plain image. The secret key is generated by using the key mixing proportion factor *K* as follows [36]:

$$K\_s = \frac{1}{256} mod \left( \sum\_{i=\lfloor \frac{(s-1)M}{2} \rfloor + 1}^{\lfloor \frac{sM}{2} \rfloor} \sum\_{j=1}^{N} o\_{ij}, 256 \right), \quad s = 1, 2, \tag{2}$$

and, the key values *ζs* is changed via the following formula:

$$
\zeta\_s \leftarrow \frac{(\zeta\_s + K\_s)}{2}, \quad s = 1, 2,\tag{3}
$$

where [*x*] denoted to the nearest integer and *ζs* denoted to *qs*0, *s* = 1, 2.

The key space of the proposed algorithm consists of the polynomial function with degree *k* and limits of [*α*, *β*] for the Newton-Raphson's method, two initial values and eight parameters for *GBNDS*. Then, for the confusion phase, select two values, *α*, *β*, and one polynomial function based on Newton-Raphson's method, and for diffusion phase, two initial values, *q*10, *q*20, and eight parameters *a*, *b*, *c*1, *c*2, *μ*1, *μ*2, *ν*1, *ν*2 for the System (1).

#### *3.2. Rows/Columns Shuffling (Confusion Phase)*

In this section, we design a technique for generating a random permutation of the integers {1, 2, ... , *<sup>n</sup>*}. Then, we shuffle the rows/columns of the plain image via the random permutation sequences.

Suppose a polynomial function of degree *s*, *p*(*x*) = ∑*si*=<sup>1</sup> *aixi*, where *as* = 0 and *s* > 1, is defined on the interval [*α*, *β*]. Take *x*0 = (*α* + *β*)/2 and Newton-Raphson's method generates the sequence {*xi*}<sup>∞</sup>*i*=<sup>0</sup> by the following formula:

$$\mathbf{x}\_{i} = \mathbf{x}\_{i-1} - \frac{p(\mathbf{x}\_{i-1})}{p'(\mathbf{x}\_{i-1})}, \quad p'(\mathbf{x}\_{i-1}) \neq 0 \quad \forall \quad i = 1, 2, 3, \dots \tag{4}$$

Suppose, the Newton-Raphson's method generates the points {*<sup>x</sup>*1, *x*2, *x*3, ... , *xn*}. To ge<sup>t</sup> more randomness, instead of *p*(*xi*), the sequence is defined as the fraction part of *p*(*xi*). This sequence depends on the polynomial *p*(*x*) and the interval [*α*, *β*].

The standard NIST SP800-22 test is used to assess the efficiency of the pseudorandom number generator(PRNG) of Newton-Raphson's method, and Table 1 gives the test results. In Table 1, the random number generator has passed all the tests. So, it has a good randomness.


**Table 1.** NIST statistical test for PRNG-Newton-Raphson's method.

Algorithm 1 is proposed to generate a random permutation of the integers {1, 2, ... , *n*} based on Newton-Raphson's method as follows:

#### **Algorithm 1** Random-Permutation algorithm

**Input:** Size of random numbers, *n*, the polynomial *p*(*x*), *α*, and *β*. **Output:** *S*, the random permutation of the integers {1, 2, . . . , *<sup>n</sup>*}. **Step 1:** Set *S* = 1, *x*0 = (*α* + *β*)/2, *x* = *p*(*<sup>x</sup>*0) − *fix*(*p*(*<sup>x</sup>*0)) **Step 2:** For *i* = 2 to *n*, compute *S* = [*S i*] *k* = *ceil*(*i* ∗ *x*) *S*([*k i*]) = *S*([*i k*]) *x*1 = *x*0 − *p*(*<sup>x</sup>*0)/*p* (*<sup>x</sup>*0) *x* = *p*(*<sup>x</sup>*1) − *fix*(*p*(*<sup>x</sup>*1)) *x*0 = *x*1 End For **Step3:***S*

> Suppose the size of the plain image is *M* × *N*. Algorithm 2 is designed to shuffle the plain image based on the random permutation sequences of Algorithm 1. It may be processed as in Algorithm 2.

#### *3.3. Diffusion Phase*

The system (1) is utilized to generate a chaotic sequence of size *M* × *N*. Then, reshape it to be of size 1 × *MN*, *Q* = {*q*1, *q*2, ... , *qMN*}. The sequence *Q* is modified using the following formula:

$$q\_i = mod(cil(q\_i \times 10^{14}), 256), i = 1, 2, \dots, MN. \tag{5}$$

**Input:** The plain image, *O*, the polynomial *p*(*x*), *α*1, *α*2, *β*1, and *β*2. **Output:** *H*, the shuffled image. **Step 1:** Set [*<sup>M</sup>*, *N*] = *size*(*O*) **Step 2:** Use Algorithm 1, with polynomial *p*(*x*), and interval [*<sup>α</sup>*1, *β*1], to generate a random permutation of size *M* for shuffling the rows, say *SRows*. **Step 3:** Use Algorithm 1, with polynomial *p*(*x*), and interval [*<sup>α</sup>*2, *β*2], to generate a random permutation of size *N* for shuffling the columns, say *SColumns*. **Step 4:** For *i* = 1 to *M*, compute For *j* = 1 to *N*, compute *<sup>H</sup>*(*<sup>i</sup>*, *j*) = *<sup>O</sup>*(*SRows*(*i*), *SColumns*(*j*)) End For j EndFori

 **Step 5:** *H*, the shuffled image.

> Moreover, the shuffled image *H* is reshaped to be of size 1× *MN*, *H* = {*h*1, *h*2, ... , *hMN*}. Finally, *XOR* is applied between each pixel in *H* and corresponding chaotic value of *X*, *D* = *XOR*(*<sup>H</sup>*, *X*) (diffusion phase). The algorithm of diffusion phase may be processed as follows:

#### **Algorithm 3** Diffusion algorithm

**Input:** The shuffled image, *H*, *q*10, *q*20, *a*, *b*, *c*1, *c*2, *μ*1, *μ*2, *ν*1, and *ν*2. **Output:** *D*, the diffusion vector. **Step 1:** Reshape *H*, *H* = {*h*1, *h*2, ..., *hMN*}. **Step 2:** Covert *H* to binary, *Hb*. **Step 3:** Set *q*1(0) = *q*10, *q*2(0) = *q*20. **Step 4:** Perform initial iterations, For *t* = 0 to 999 *q*1(*<sup>t</sup>* + 1) = *q*1(*t*) + *<sup>ν</sup>*1*q*1(*t*)[(<sup>1</sup> − *μ*1)(*<sup>a</sup>* − <sup>2</sup>*bq*1(*t*) − *bq*2(*t*)) − *c*1] *q*2(*<sup>t</sup>* + 1) = *q*2(*t*) + *<sup>ν</sup>*2*q*2(*t*)[(<sup>1</sup> − *μ*2)(*<sup>a</sup>* − <sup>2</sup>*bq*2(*t*) − *bq*1(*t*)) − *c*2] End For **Step 5:** Set *q*1(0) = *q*1(1000), *q*2(0) = *q*2(1000). **Step 6:** For *t* = 0 to *MN* − 1 *q*1(*<sup>t</sup>* + 1) = *q*1(*t*) + *<sup>ν</sup>*1*q*1(*t*)[(<sup>1</sup> − *μ*1)(*<sup>a</sup>* − 1(*t*) − *bq*2(*t*)) − *c*1] *q*2(*<sup>t</sup>* + 1) = *q*2(*t*) + *<sup>ν</sup>*2*q*2(*t*)[(<sup>1</sup> − *μ*2)(*<sup>a</sup>* − <sup>2</sup>*bq*2(*t*) − *bq*1(*t*)) − *c*2] *q*(*<sup>t</sup>* + <sup>1</sup>)=(*q*1(*<sup>t</sup>* + 1) + *q*2(*<sup>t</sup>* + 1))/2 End For **Step 7:** Preprocess the values of *Q* = {*q*(1), *q*(2), ..., *q*(*MN*)} as follows: *q*(*t*) = *mod*(*ceil*(*q*(*t*) ∗ <sup>10</sup><sup>14</sup>), <sup>256</sup>), *t* = 1, 2, ..., *MN*. **Step 8:** Covert *Q* to binary, *Qb*. **Step 9:** Perform *XOR* between *Hb* and *Qb*, say *D* = *XOR*(*Hb*, *Qb*).

#### *3.4. The Encryption/Decryption Algorithm*

The encrypted image is produced from Algorithm 3 by reshape diffusion vector *D* to be of size *M* × *N*, say *E*. The whole image encryption algorithm may be processed as in the Algorithm 4.

The Algorithm 4 (Image Encryption based on General Bischi-Naimzadah Duopoly System) will be referred to as **IEGBNDS** algorithm. Indeed, **IEGBNDS** algorithm can be applied to encryp<sup>t</sup> the color images. We can decompose color images into three grayscale images of red, green and blue colors (R, G, B components). After that we can encryp<sup>t</sup> them into their corresponding cipher images by applying the proposed algorithm. Then by re-joining the three cipher images of the R, G, B components, the color cipher image can be obtained.

**Algorithm 4** Image encryption algorithm

**Input:** The plain image, *O*, the polynomial *p*(*x*), *α*, *β*, *q*10, *q*20, *a*, *b*, *c*1, *c*2, *μ*1, *μ*2, *ν*1, and *ν*2.

**Output:** *E*, the encrypted image.

**Step 1:** Read the plain image, *O*.

**Step 2:** Generate the secret key by using the key mixing proportion factor.

**Step 3:** Call Algorithm 2 to ge<sup>t</sup> the shuffled image *H*.

**Step 4:** Call Algorithm 3 to ge<sup>t</sup> the diffusion vector *D*.

**Step 5:** Covert *D* to decimal, say *Dd*.

**Step 6:** Change the dimension of *Dd* to *M* × *N*, say *E*.

**Step 7:** *E* is the encrypted image.

> The decryption algorithm is the inverse steps of **IEGBNDS** algorithm. Figure 4 displays the block diagram of **IEGBNDS** algorithm.

**Figure 4.** Block diagram of the proposed algorithm.

#### **4. Experimental Results**

The **IEGBNDS** algorithm has been applied to several 512 × 512 pixel gray-scale images and very promising results have been accomplished. All codes are accomplished on a Windows 10 Laptop with Intel(R) Core(TM) i7 2.40 GHz, CPU with 12 GB RAM using MATLAB R2016b.

#### *4.1. Key Space Analysis*

The key space must be large enough to hold out against brute-force attack. It must be above the value 2<sup>100</sup> [39]. The key space of the **IEGBNDS** algorithm consists of the polynomial function with degree *k* and limits of [*α*, *β*] for the Newton-Raphson's method, two initial values and eight parameters for *GBNDS*. If the accuracy 10−<sup>14</sup> has been used then it will be equal to 10<sup>14</sup>(*k*+<sup>1</sup>) + <sup>10</sup><sup>168</sup>(>> <sup>2</sup><sup>100</sup>). Table 2 gives the key space of the **IEGBNDS** algorithm compared to some recent algorithms in literature.

**Table 2.** Key space of the **IEGBNDS** algorithm compared to some recent algorithms in literature.


#### *4.2. Histogram Analysis*

In a good encryption algorithms, the distribution of the pixel intensity values within a cipher image should be as similar to the uniform distribution as possible. Figures 5 and 6 show that the histograms of the cipher image is very similar to the uniform distribution. As the *χ*2 statistical test is used to measure the nearness of produced histograms to the uniform histogram. The statistical *χ*2-value is evaluated by [6]:

$$\chi^2 = \sum\_{i=1}^{256} \frac{(E\_i - \mathfrak{e}\_i)^2}{\mathfrak{e}\_i} \,\,\,\,\,\tag{6}$$

where the length of all possible values in an image is 256, *Ei* is the observed event frequencies of *i* − 1 and *ei* is the expected event frequencies of *i* − 1, *i* = 1, 2, ..., 256. By evaluating the *χ*2-value with the level of significance *α* = 0.05, we go<sup>t</sup> *<sup>χ</sup>*0.05(255) = 293.25. So, Both distributions are nearly equal if *χ*<sup>2</sup>(255) < 293.25. Table 3 shows that all tested images are smaller than 293.25. Therefore, the cipher images histograms are close to the uniform distributions. In other words, an attacker cannot retrieve any valuable information from them.

**Figure 5.** Plain images, cipher images and their corresponding histograms.

(**m**) Moon\_surface (**n**) Histogram of (**m**) (**o**) Cipher image of (**m**) (**p**) Histogram of (**o**)

**Figure 6.** Plain images, cipher images and their corresponding histograms.

**Table 3.** *χ*2-values of the histograms of the cipher images at *a* = 11.25, *b* = 0.5, *c*1 = 0.20, *c*2 = 0.30, *μ*1 = 0.002, *μ*2 = 0.60, *ν*1 = 0.20, *ν*2 = 0.70, *q*10 = 0.10, and *q*20 = 0.20.


Histogram Statistics

The variance and standard deviation are dispersion metrics applied in graphic histograms to help the effects of visual inspection. They calculate how often the elements of a dataset differ across the average with respect to each other. The same average value (mean) can be in two datasets, but the differences may be dramatically different. If the histogram has the lower variance then it has the more uniform of the graphic histogram, which is calculated by the following formula:

$$V = \frac{1}{256} \sum\_{i=1}^{256} (\theta\_i - \bar{\theta})^2,\tag{7}$$

where

$$\theta = \frac{M \times N}{256},$$

*θi* is the frequency for each pixel's value from 0 − 255 of the histogram, *i* = 1, 2, ... , 256, ¯ *θ* is the histogram mean.

The standard deviation helps us to know the arithmetic average of the dataset's variations relative to the mean. It is calculated as follows:

$$S = \sqrt{V} \,\,\,\,\,\tag{9}$$

where *V* is the histogram variance.

Table 4 presents the histogram statistics for the plain and cipher images of the tested images for the **IEGBNDS** algorithm and the encryption algorithm in Reference [41].

**Table 4.** Histogram statistics for the **IEGBNDS** algorithm and the encryption algorithm in Reference [41].


#### *4.3. Entropy Analysis*

Information entropy [7] is utilized to detect the randomness of the cipher image. It is computed as follows:

$$H = \sum\_{i=0}^{255} P\_i \log\_2(\frac{1}{P\_i}) ,\tag{10}$$

where *Pi* is the probability associated with gray level *i*. The largest value of the entropy reflects the randomness of the encrypted image. The maximum value of the entropy in our case is 8. Table 5 gives the information entropy for the plain and cipher images of the tested images. All values of entropy based on our algorithm are close to 8. In addition, the **IEGB-NDS** algorithm gives average better than most averages of the listed recent algorithms. Based on the results of entropy, the **IEGBNDS** algorithm has reasonable protection.

**Table 5.** Information entropy analysis of the **IEGBNDS** algorithm compared to some recent algorithms in literature.


#### *4.4. Correlation Coefficients Analysis*

In the plain image, adjacent pixels have strong relationships. So, reducing these relationships is required to hold out against statistical attacks. The correlation coefficient between two adjacent pixels, *θ* and *φ*, is defined as [6]:

$$r\_{\theta\phi} = \frac{Cov(\theta, \phi)}{\sqrt{\zeta} (D(\theta) D(\phi))},\tag{11}$$

where

$$\text{Cov}(\theta, \phi) = \frac{1}{N} \sum\_{m=1}^{N} (\theta\_m - E(\theta))(\phi\_m - E(\phi)),\tag{12}$$

$$E(\theta) = \frac{1}{N} \sum\_{m=1}^{N} \theta\_{m\_{\prime}} \tag{13}$$

and

$$D(\theta) = \frac{1}{N} \sum\_{\text{m}=1}^{N} \left(\theta\_{\text{m}} - E(\theta)\right)^2,\tag{14}$$

where *θ* and *φ* are selected randomly. 3000 pairs of adjacent pixels are chosen randomly from the plain and cipher images. Figure 7 displays the pixel intensity value's distribution of 3000 pairs for the Barbara image and its encrypted image in the three directions, diagonal, horizontal, and vertical. The correlation coefficients of the three directions for the **IEGB-NDS** algorithm compared to some recent encryption algorithms based on the average of the correlation coefficients are given in Table 6. Table 6 shows that the **IEGBNDS** algorithm outperforms all of them at least in one direction. Also all values of *<sup>r</sup>θφ* for the cipher images are close to zero. So, it can protect the image information.

**Table 6.** Correlation coefficient of the cipher images based on the **IEGBNDS** algorithm compared to some recent encryption algorithms in literature.


**Figure 7.** Distribution of adjacent pixels in the plain image (**<sup>a</sup>**,**c**,**<sup>e</sup>**) and the cipher image (**b**,**d**,**f**) for Barbara image in the three directions, diagonal, horizontal, and vertical.

#### *4.5. Differential Attack Analysis*

The protection against differential attacks is required for any image encryption algorithm. There are two main measurements, (1) *NPCR* (Number of Pixel Change Rate), and (2) *UACI* (Unified Average Changing Intensity). These measurements evaluated the amount of differences between two images, and can be defined as [5]:

$$NPCR = \frac{\sum\_{m,n} D(m,n)}{M \times N} \times 100\% \,\tag{15}$$

$$dIACI = \frac{1}{M \times N} \left[ \sum\_{m,n} \frac{|O(m,n) - E(m,n)|}{255} \right] \times 100\% \tag{16}$$

where

$$D(m,n) = \begin{cases} 0 & \text{if } O(m,n) = E(m,n), \\ 1 & \text{otherwise.} \end{cases} \tag{17}$$

A single pixel of the plain image is selected randomly and it modified to 255 − *v*, where *v* is the original intensity value of pixel. The same key is utilized to encryp<sup>t</sup> the modified image and the plain image. Then, *NPCR*, and *UACI* are calculated using the two cipher images. Table 7 shows *NPCR* and *UACI* for the tested images and compared them to some recent algorithms in literature. The **IEGBNDS** algorithm offers a good level of

security. Based on the averages of *NPCR* and *UACI*, the **IEGBNDS** algorithm outperforms all of them at least in one of the two measures. So, the **IEGBNDS** algorithm can be useful against differential attacks.

**Table 7.** NPCR and UACI of the tested images using the **IEGBNDS** algorithm and the recent algorithms.


#### *4.6. Key Sensitivity Analysis*

The sensitivity to the secret key is one of the important features of an excellent encryption algorithm. During the restoring plain image (decryption process), small changes in one of the initial values or parameter are made and we will observe the restoring image via the modified secret key. Table 8 shows the restoring images using the true secret key and the modified secret keys. The plain image cannot be restored by any of modified secret keys. Therefore, the **IEGBNDS** algorithm is highly sensitive to any changes of the secret key.

> **Table 8.** The result of key sensitivity analysis.

#### *4.7. Robustness Analysis*

In real life, noise or data loss is occurred and the **IEGBNDS** algorithm is tested against these problems. Salt&Pepper noise with different densities are added to the cipher image of lena with size 512 × 512. Table 9 shows the decrypted images of the noisy encrypted images. Moreover, the decryption image of the encryption image with some data loss is shown in Table 9. Based on the result of Table 9, The **IEGBNDS** algorithm can be robust against the noise and data loss attacks.

**Table 9.** Robustness analysis of the **IEGBNDS** algorithm for lena image with size 512 × 512.

#### *4.8. Chosen Plaintext Attack Analysis*

The **IEGBNDS** algorithm is sensitive to the key generation, *Ks*, in Equation (2) and different sequences will be generated by small changes in the plain image. So, the **IEGBNDS** algorithm can hold out against the plaintext attacks. Now, we will examine the **IEGBNDS** algorithm against the chosen plaintext attack. Suppose the attacker has the encrypted image and the running of the **IEGBNDS** algorithm for a short time. The algorithm of Reference [42] will be used to examine our algorithm against chosen plaintext attack. In this algorithm, the following notations will be used:

*P*: plain image,

*E*: encrypted image of *P*,

*D*: designed image, where *dmn* = 0, *m* = 1, 2, . . . , *M*, *n* = 1, 2, . . . , *N*, *ED*: encrypted image of *D*,

*DE*: decrypted image of *E*.

The *XOR* operations between the pixels of *E* and *ED* are performed to obtain the plain image *P*. Based on the result of Figure 8, the decrypted image is totally unlike the plain image. Therefore, the **IEGBNDS** algorithm can resist chosen plaintext attack.

**Figure 8.** Analysis of chosen plaintext attack: (**a**) Encrypted image *E*, (**b**) designed image *D*, (**c**) encrypted image of *D*, (**d**) Decrypted image *DE*.

#### *4.9. Computational Analysis*

The average times of encryption and decryption algorithm for one hundred time are 34.11 ms and 30.57 ms (Tested image of size 512 × <sup>512</sup>), respectively. On the other hand, for the tested image of size *M* × *N*, the encryption algorithm needs 5 *MN* + *M* + *N* + 2000 operations. The complexity time for the decryption algorithm is equal to the complexity time of the encryption algorithm. Table 10 shows that the running time of the **IEGBNDS** algorithm is effective compared to some recent image encryption algorithms such as in Reference [40] by Shakiba and Reference [23] by Cao et al.

**Table 10.** Running time of the encryption for the **IEGBNDS** algorithm and the recent algorithms.


#### *4.10. NIST Statistical Tests*

NIST were established to test the randomness of generating cipher images created by encryption algorithms [43]. For the **IEGBNDS** algorithm, it is used to check the randomness of a sequence that consists of 100 cipher images of length 512 × 512 × 8 = 2,097,152 bits. They were generated by using different random secret keys. Table 11 presents the results for 15 tests and all of them passed these tests.

**Table 11.** NIST statistical test for 100 cipher images by the **IEGBNDS** algorithm.

