# Hash Based DNA Computing Algorithm for Image Encryption
## 3 Methods
### Content-Aware Encryption Module
### Pixel Correlation Analysis

Permutation and diffusion operations are used to scramble adjacent pixels between images, thus reducing the correlation between adjacent pixels and improving the security

Figure 5: The corresponding histograms for different plain and cipher images, where (**a–f**) are input plain images of ‘Lena’, ‘Poster’, ‘Street’, ‘Subway’, ‘ID Card’, ‘Hohai University’, and (**g–l**) are their corresponding cipher images. after image encryption. We can calculate the correlation coefficient between \(a\) and \(b\) to evaluate such correlation effects

\[\left\{ \begin{array}{l}r_{ab}=\frac{\mathrm{cov}(a,b)}{\sqrt{D(a)}\sqrt{D(b)}}\\ \mathrm{cov}(a,b)=\frac{1}{N}\sum_{i=1}^{N}(a_{i}-E(a))(b_{i}-E(b))\\ D(a)=\frac{1}{N}\sum_{i=1}^{N}(a_{i}-E(a))^{2}\\ E(a)=\frac{1}{N}\sum_{i=1}^{N}a_{i}\end{array} \right. \tag{3}\]

where \(\mathrm{cov}(a,b)\), \(D(a)\) and \(E(a)\) are defined as the covariance, mean square and expected error, respectively. Table 2 shows the correlation coefficients of the plain and cipher image, where we can observe that the pixel correlation has been significantly reduced by comparing between both images. Correspondingly, Figure 6 shows the comparison of image correlation before and after encryption, which proves that the proposed method can effectively reduce the correlation in three directions. ### Information Entropy Analysis

Information entropy is used to measure the uncertainty of data, where higher information entropy refers to larger complexity for cracking. Supposing the number of keys of an encryption algorithm is K-bit, the ideal information entropy should be K. To evaluate the uncertainty of the data, i.e., the diffusion performance, information entropy can be calculated as follows:

\[H=-\sum_{i=1}^{256}p(e_{i})\log_{2}p(e_{i}) \tag{4}\] \begin{table}
\begin{tabular}{c c c c c c c} \hline \hline \multirow{2}{*}{**Images**} & \multicolumn{3}{c}{**Plain Image**} & \multicolumn{3}{c}{**Cipher Image**} \\ \cline{2-7}  & **V** & **H** & **D** & **V** & **H** & **D** \\ \hline Baboon & 0.8813 & 0.7524 & 0.7638 & 0.0039 & 0.0037 & 0.0048 \\ Bridge & 0.9344 & 0.9531 & 0.9812 & \(-\)0.0089 & 0.0049 & \(-\)0.0017 \\ Chest & 0.9674 & 0.9892 & 0.9816 & \(-\)0.0037 & 0.0045 & \(-\)0.0081 \\ Lena & 0.9832 & 0.9729 & 0.9631 & 0.0017 & 0.0026 & 0.0033 \\ Hohai & 0.8681 & 0.8724 & 0.9076 & \(-\)0.0018 & \(-\)0.0089 & 0.0094 \\ University & & & & & & \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Results of correlation coefficients analysis on several testing images. Figure 6: Correlation coefficients distributions of ‘Lena’ (**a**) and its corresponding cipher image (**e**), where (**b**,_f_) are distributions in horizontal direction, (**c**,_g_) are distributions in vertical direction, and (**d**,_h_) are distributions in diagonal direction. where \(p(e_{i})\) represents the probability of the pixel being \(i\). The information entropy of five test images is 7.987421 (Poster), 7.996523 (Street), 7.989923 (Subway), 7.998615 (ID Card) and 7.988991 (Hohai University), where all the information entropy is close to 8, implying that the proposed method performs a pixel diffusion with an optimized performance. ### Sensitivity Analysis

By modifying values of a few pixels and comparing results, differential attacks could help attackers to easily obtain the rules of encryption. Therefore, the cryptosystem is required to have a certain sensitivity to resist pixel modifications. We adopt a unified average changing intensity (UACI) and number of pixels change rate (NPCR) to measure such sensitivity:

\[\left\{ \begin{array}{l}NPCR=\frac{1}{H\times W}\sum_{i=1}^{H}\sum_{j=1}^{W}D _{ij}\times 100\%\\ UACI=\frac{1}{H\times W}\sum_{l=1}^{H}\sum_{j=1}^{W}\left(\frac{I(i,j)-I^{ \prime}(i,j)}{255}\right)\times 100\%\end{array} \right. \tag{5}\]

where \(D_{ij}=\left\{ \begin{array}{l}1,I(i,j)\
eq I^{\prime}(i,j)\\ 0,I(i,j)=I^{\prime}(i,j)\end{array} \right..\)\(I\) and \(I^{\prime}\) are the original and the modified image, respectively.