# Cryptographic Encryption and Optimization for Internet of Things Based Medical Image Security
## 3 Proposed Method
### Image Encryption Process  
With confusion and diffusion technologies and asymmetric image encryption, this work develops a groundbreaking technique. The picture encryption scheme is Algorithm 1. Figure 2 shows the flow of image encryption. The precise encryption procedure is detailed as follows.  
Step 1: choosing prime numbers \(p\) and \(q\) to create a new key  
\[n=p\times q,\varphi(n)=(p-1)(q-1) \tag{4}\]  
Step 2: Using the hostile orchestration technique, create a private key \(d\) and a public key \(e\).  
Step 4: Public key \(e\) is used to calculate the public ciphertext \(c_{i}=y_{0i}^{e}\) mod \(n,\ i=1,\ 2,\ 3,\ 4\) before Equation (5) is applied to determine the parameter pairs \(a\) and \(b\) of the Arnold map:  
\[\begin{cases}y_{01}=x_{01}+x_{02},\\ y_{02}=x_{02}+x_{03},\\ y_{03}=x_{03}+x_{04},\\ y_{04}=x_{01}+x_{04},\end{cases} \tag{5}\]  
\[\begin{cases}a_{1}=fix(x_{01}+sqrt(\log(c_{1}+y_{01})))\\ b_{1}=fix(x_{02}+sqrt(\log(c_{2}+y_{02})))\\ a_{2}=fix(x_{03}+sqrt(\log(c_{3}+y_{03})))\\ b_{2}=fix(x_{04}+sqrt(\log(c_{4}+y_{04})))\end{cases} \tag{6}\]  
Step 5: To produce chaotic sequences \(s\) and \(r\), insert the following parameters into the generalised Arnold map equation: \(a_{1}\), \(b_{1}\), \(a_{2}\), and \(b_{2}\). Then, change the values produced into the 0-255 range.  
\[S=mod\Big{(}floor\Big{(}(s+100)\times 10^{14}\Big{)},256\Big{)}, \tag{7}\]  
\[R=mod\Big{(}floor\Big{(}(r+100)\times 10^{14}\Big{)},256\Big{)} \tag{8}\]  
Step 6: Save the simple as it appears as \(P\) and, using the generated key stream \(S\), do the follows XOR diffusing procedure to acquire image \(A\):  
\[A_{i}=A_{i-1}\oplus P_{i}\oplus S_{i} \tag{9}\]  
where \(A_{i}\), \(P_{i}\) and \(S_{i}\) stand in for the components \(A\), \(P\), and \(S\).  
Step 7: \(S\) is converted into a matrix. Next, apply cyclical scramble to the initial row and column of the image matrix \(S\), where image \(A\) is located, to create image \(B\).  
Step 8: To create image \(C\), an additive mode diffusion operation is employed with image \(B\) and the chaotic sequence \(R\).  
\[C_{i}=C_{i-1}+B_{i}+R_{i}mod\ 256 \tag{10}\]  
where \(C_{i}\), \(B_{i}\), and \(R_{i}\), are the components of \(C\), \(B\), and \(R\), respectively.  
Step 9: discovered after two iterations of computation.  
The three channels \(R\), \(G\), and \(B\) can be used to treat the color image as three grayscale images. Therefore, each channel uses the same encryption.  
The encryption process supplies two inputs: the plaintext version of the data picture and the encryption key. In this case, the length of the unique image data bit stream is divided into the hostile orchestration building blocks. Each line of the array's byte components corresponds to one of the image's output lines, and the image's lines are  
Figure 2: The image encryption algorithm.  
completely encrypted. The array's byte components are stored in row order from left to right.  
```
Input : original image \(P\), sec ret keys \(x_{01},x_{02},x_{03},x_{04}\)  Examine the image's size. \(M\times N\)  Find the Arnold map's a and b using Equations (5) and (6) using RSA. and \(x_{01},x_{02},x_{03},x_{04}\)  Create the two important streams \(S\) and \(R\) using Equations (7) and (8)  Get X and Y by sorting a row and a column from \(S\). \(B=P\oplus S;//\)Perform XOR diffusion operations \(For\ i=1:\ M\) \(D(X(i),:)=B(i,:);//\)Confusion on the row direction end \(For\ i=1:N\) \(E(:,Y(i))=D(:,i);//\)Confusion on the column direction end \(C=mod\ (E+R,256);//\)Perform additive mode diffusion operation Output: encryption image \(C\)
```  
**Algorithm 1**Image encryption pseudocode