## 4 Design, Implementation and Analysis Results of the Image Encryption Algorithm
### Design of Image Encryption Algorithm  
In the algorithm developed for image encryption, encryption is realized by performing sub-byte operations with S-box structure used for confusion in block encryption algorithms. An S-box structure with strong cryptographic features makes the encryption process very robust and resistant to attacks. In this study, by using the developed S-box generation algorithm, three S-boxes with strong cryptographic properties have been generated and the performance results of S-boxes are given in the previous section. The block diagram for the designed encryption algorithm is shown in Figure 6.  
\begin{table}
\begin{tabular}{c c c c c c c c c} \hline \hline \multirow{2}{*}{**S-Box**} & \multicolumn{3}{c}{**Nonlinearity**} & \multirow{2}{*}{**BIC-SAC**} & \multirow{2}{*}{**BIC-Nonlinearity**} & \multicolumn{3}{c}{**SAC**} & \multirow{2}{*}{**Max**} & \multirow{2}{*}{**DP**} \\  & **Min** & & & & & & & \\ \hline
**Proposed S-Box1** & 104 & 106 & 110 & 0.4988 & 103.857 & 0.4018 & 0.4946 & 0.5781 & 10 \\
**Proposed S-Box2** & 104 & 107 & 108 & 0.4997 & 103.357 & 0.4218 & 0.5029 & 0.5937 & 10 \\
**Proposed S-Box3** & 106 & 106 & 108 & 0.5058 & 104.14 & 0.3918 & 0.4916 & 0.5781 & 10 \\
**[PERSON]** [24] & 98 & 103.2 & 108 & 0.5031 & 104.2 & 0.3761 & 0.5058 & 0.5975 & 12 \\
**[PERSON]** [25] & 99 & 103.4 & 106 & 0.4995 & 103.3 & 0.4140 & 0.4987 & 0.6015 & 10 \\
**[PERSON]** [26] & 102 & 104 & 106 & 0.5070 & 103.8 & 0.4850 & 0.5072 & 0.5150 & 12 \\
**[PERSON]** [27] & 104 & 106 & 108 & 0.49763 & 103.857 & 0.3906 & 0.5063 & 0.5937 & 12 \\
**[PERSON]** [28] & 84 & 100 & 106 & 0.4962 & 101.9 & 0.3712 & 0.4825 & 0.6256 & 16 \\
**[PERSON]** [29] & 100 & 104.2 & 109 & 0.4988 & 103.3 & 0.3906 & 0.4931 & 0.5703 & 12 \\
**[PERSON]** [60] & 100 & 103 & 106 & 0.5024 & 103.1 & 0.4218 & 0.5000 & 0.6093 & 14 \\
**[PERSON]** [30] & 104 & 106 & 110 & 0.5058 & 103.4 & 0.4218 & 0.5039 & 0.5937 & 10 \\
**[PERSON]** [31] & 98 & 105 & 110 & 0.4994 & 105.7 & 0.4062 & 0.4926 & 0.5937 & 12 \\
**[PERSON]** [32] & 96 & 103 & 106 & 0.5010 & 100.3 & 0.3906 & 0.5039 & 0.6250 & 12 \\
**[PERSON]** [61] & 102 & 104 & 106 & 0.5019 & 103.5 & 0.4825 & 0.5018 & 0.5175 & 10 \\
**[PERSON]** [33] & 102 & 105.2 & 108 & 0.5053 & 104.2 & 0.4080 & 0.5050 & 0.5894 & 12 \\
**Skipjack S-Box** [34] & 104 & 105.7 & 108 & 0.4994 & 104.1 & 0.3986 & 0.5032 & 0.5938 & 12 \\
**AES S-Box** [35] & 112 & 112 & 112 & 0.5046 & 112 & 0.4531 & 0.5048 & 0.5625 & 4 \\ \hline \hline \end{tabular}
\end{table}
Table 4: The comparison of chaos-based S-box.  
In the encryption algorithm, first, the random number obtained from the random bit sequences generated by the chaos-based RNG and the image file are subjected to \"bitxor\" process over pixels. Number generation by chaos-based RNG is performed as described in the S-box generation algorithm. Then, sub-byte process is performed on the image with S-boxes having strong cryptographic properties generated by the S-box generation algorithm. In the sub-byte process, row and column positions of pixels of the image are replaced with the eight-bit value on the S-box. The S-box to be used during this replacement is also determined by mod-3 operation over the numbers in the random number array generated from the \(x\)-phase of the chaos-based RNG. In this way, the S-box for sub-byte process is randomly selected. After sub-byte process, an encrypted image file is obtained. By applying the reverse of these operations for decryption, the original image is obtained.