# Hash Based DNA Computing Algorithm for Image Encryption
## 3 Methods
### Overall Framework  
We begin with an introduction to a basis of DNA computing in encryption. DNA bases are classified into four types, namely, adenine (A), thymine (T), cytosine (C) and guanine (G). It is worth noting that the former two types are complementary pairs, and so are the latter two types. We then describe rules for DNA-based sequence encoding, which uses a binary encoding idea to represent the input sequence under rules shown in Table 1 with four bases, i.e., A, C, G and T. With the aid of encoding rules of Table 1, we can convert binary sequence into a DNA-based encoding form for further computation. For example, under rule 2, A, C, G and T are represented as 00, 01, 10, and 11, respectively. If a pixel in the input image refers to 179 in gray levels and its binary representation is 10110011, its corresponding DNA-based encoding sequence should be G-T-A-T under rule 2. During decoding, if a DNA-based encoding sequence is G-A-T-C under rule 2, its corresponding binary value should be 10001101.  
We then demonstrate the overall framework in Figure 1, which consists of sender and receiver structures. Specifically, the whole process of encryption inside the sender can be described as follows:  
\begin{table}
\begin{tabular}{c c c c c c c c c} \hline \hline  & **Rule 1** & **Rule 2** & **Rule 3** & **Rule 4** & **Rule 5** & **Rule 6** & **Rule 7** & **Rule 8** \\ \hline A & 00 & 00 & 11 & 11 & 10 & 01 & 10 & 01 \\ C & 10 & 01 & 10 & 01 & 00 & 00 & 11 & 11 \\ G & 01 & 10 & 01 & 10 & 11 & 11 & 00 & 00 \\ T & 11 & 11 & 00 & 00 & 01 & 10 & 01 & 10 \\ \hline \hline \end{tabular}
\end{table}
Table 1: DNA-based binary encoding rules, which uses different rules to represent binary values with DNA bases.  
**Step 1.** Feed the initial key \(K\) and the input image \(I\) into the DNA hash encoding module, which computes the rule selection sequence \(Q_{rule}\) and DNA-encoded Sequence \(Q_{1}\).  
**Step 2.**\(K\) and \(Q_{1}\) are regarded as input of Content-aware Encryption module, which computes new sequence \(Q_{2}\) with permutation and diffusion, thus encoding complexity for high unbreakability.  
**Step 3.**\(Q_{rule}\) and \(Q_{2}\) are fed into the DNA encoding module, which encodes \(Q_{2}\) by utilizing \(Q_{rule}\) to generate a binary bitstream under DNA encoding rules. Afterwards, we transfer the generated bitstream as a ciphered image \(C\) with \(H^{{}^{\prime}}\times W^{{}^{\prime}}\).  
**Step 4.** Transmit \(C\) from the sender to the receiver via Internet.  
The whole process of decryption inside the receiver can be described as follows:  
**Step 5.** Regarding \(C\) as input, the receiver sends it to DNA hash decoding module with the initial key \(K\), thus generating the rule selection sequence \(Q_{rule}\) and a DNA-based decoding sequence \(Q_{1}^{d}\). It is noted that we keep the rule selection sequence exactly the same to ensure the consistency of decryption content.  
**Step 6.** Feed \(K\) and \(Q_{1}^{d}\) into the content-aware decryption module for the reversed permutation and diffusion, thus generating a reversed DNA-based decoding sequence \(Q_{2}^{d}\).  
**Step 7.** Feed \(Q_{2}^{d}\) and \(Q_{rule}\) into the DNA decoding module, which uses \(Q_{rule}\) as the rule selector to decode \(Q_{2}^{d}\) into the binary bitstream \(I_{bit}\). Finally, we transfer \(I_{bit}\) into the output image \(I\) for computation. Note that the input and output image should remain the same due to the general principles of encryption.