# Hash Based DNA Computing Algorithm for Image Encryption
## 3 Methods
### Content-Aware Encryption Module
```
Input: Initial Key \(K\), Rule Selection Sequence \(Q_{rule}\), Permutated Sequence \(Q_{1}^{p}\) Output: Permutated and Diffused Sequence \(S_{2}\)
1 Convert the plain image \(I\) into a binary bitstream \(I_{bit}\);
2\(\text{length}=\text{Length}(S_{p})\);
3\(HASH_{K}=\text{SHA256}(K)\);
4\(H_{1}=HASH_{K}(128:191)\) ; \(H_{2}=HASH_{K}(192:255)\);
5\(x_{1}=modf\big{(}H_{1}/10^{15}\big{)}\);
6\(p=modf\big{(}H_{2}/10^{15}\big{)}\);
7 For(\(t=0\) to \(length/2\));
8\(x_{t+1}=PWLCM(x_{t},p)\);
9\(X=[x_{0},x_{1},...,x_{length/2}]\);
10\(Y=mod(floor(X\times 10^{15}),256)\);
11\(T=\)DNA Encoding Table;
12 For(\(i=0\) to \(length/2\));
13\(S_{key}(i)=T(S_{rule}(i),Y(2i,2i+1))\);
14\(TA=\) DNA ADD Operation Table;
15\(TS=\) DNA SUB Operation Table;
16\(TX=\) DNA XOR Operation Table;
17 If(in encryption process);
18\(D(0)=TA(Q_{p}(0),S_{key}(0))\);
19\(D(0)=TX(D(0),S_{key}(0))\);
20 For(\(i=0\) to length);
21 If\(\text{mod}\,(i,2)==1\);
22\(D(i)=TX(Q_{p}(i),S_{key}(i))\) ; \(D(i)=TX(D(i),D(i-1))\);
23 Else;
24\(D(i)=TA(Q_{p}(i),S_{key}(i))\) ; \(D(i)=TX(D(i),D(i-1))\);
25 Elif(in decryption process);
26 For(\(i=length\) to \(0\));
27 If\(\text{mod}\,(i,2)==1\);
28\(D(i)=TX(Q_{p}(i),S_{key}(i))\) ; \(D(i)=TX(D(i),Q_{p}(i-1))\);
29 Else;
30\(D(i)=TA(Q_{p}(i),Q_{p}(i))\) ; \(D(i)=TX(D(i),S_{key}(i-1))\);
31\(D(0)=TA(Q_{p}(0),S_{key}(0))\);
32\(D(0)=TX(D(0),S_{key}(0))\);
33\(Q_{2}=D(0:length-1)\) Output Permmutated and Diffused Sequence \(Q_{2}\);
```

**Algorithm 4**DNA Sequence Diffusion Process

## 4 Experiment and Analysis

We firstly introduce the experiment settings and implementation details. Then, we perform variants of the analysis to verify the resistance against different attacks. Afterwards, we perform ablation and computation analysis to evaluate performance. Finally, the comparison experiments are conducted. ### Experiment Settings and Implementation Details

We deploy the proposed encryption system in TCP/IP environment. We connected two computers through the Tenda-AC71200M router, thus forming a simple wireless LAN environment. Specifically, the original image is provided by a laptop (sender) and encrypted into a cipher image by the proposed method. Then, the cipher image is transmitted to another laptop (receiver) via IP Messenger protocol and decrypted into a plain image. It is noted that we use two computers with the same configurations to simulate the sender and receiver. Both computers are equipped with an Intel Core i5-12400F CPU, NVIDIA RTX 3060 Ti GPU, and 16 GB memory. Additionally, the encryption method is implemented based on Python 3.8, and the initial key is set to 'GOOD-LUCK'. ### Key Space Analysis

Key space is defined as the size of a key range, i.e., the number of keys, where different encryption algorithms have their own specific key space. Essentially, we should ensure that the key space is large enough to withstand brute force attacks. Specifically, we can calculate that the size of the key space of the proposed method is \(S=(0.5\times 10^{15})^{2}\times(1\times 10^{15})^{2}\times(80\times 10^{14})^{3} \times(500\times 10^{14})=6.410^{127}\approx 2^{418}\). Obviously, such a large key space ensures the capability to resist brute force attacks. ### Histogram Analysis

The statistical analysis attack refers to the fact that attackers can obtain a quantity of information by analyzing the distribution of image pixel values. To verify the effectiveness of the proposed method against the statistical analysis attack, we compare the pixel value distribution of the original and cipher image. As shown in Figure 5a-e, the histogram of the original image fluctuates greatly, where attackers can easily construct effective attack strategies. Figure 5f-j shows the corresponding cipher images and pixel histograms, which proves that the encrypted image can effectively hide image information to resist statistical analysis attacks.