# Dynamic Analysis of Modified Duffing System via Intermittent External Force and Its Application
## 4 Algorithm Design and Information-Encryption Application
### Algorithm Design  
According to the MD system, a simple encryption algorithm is given, including scrambling encryption and chaos XOR encryption. First, the pseudorandom sequence was designed with the following steps.  
**Step 1**: Generate pseudorandom sequence from MD system.  
The fourth-order Runge-Kutta algorithm was used to solve MD System (10), and it is given by  
\[\left\{\begin{aligned} \mathbf{X}_{m+1}&=\mathbf{X}_{m}+h \cdot\frac{(\mathbf{d}_{1}+2\mathbf{d}_{2}+2\mathbf{d}_{3}+\mathbf{d}_{4})}{6}\,,\\ \mathbf{d}_{1}&=f\left(t_{m},\ \mathbf{X}_{m}\right),\\ \mathbf{d}_{2}&=f\left(t_{m}+\frac{h}{2},\ \mathbf{X}_{m}+h \cdot\frac{\mathbf{d}_{1}}{2}\right),\\ \mathbf{d}_{3}&=f\left(t_{m}+\frac{h}{2},\ \mathbf{X}_{m}+h \cdot\frac{\mathbf{d}_{2}}{2}\right),\\ \mathbf{d}_{4}&=f\left(t_{m}+h,\ \mathbf{X}_{m}+h\cdot \frac{\mathbf{d}_{3}}{2}\right),\end{aligned}\right. \tag{19}\]  
where \(\mathbf{X}=[x,\ y]\), \(\mathbf{X}_{m}\) is the \(m\)-th value of variable \(\mathbf{X}\), \(h\) is the calculation step, and \(\mathbf{d}_{1},\ \mathbf{d}_{2},\ \mathbf{d}_{3},\ \mathbf{d}_{4}\) are the derivatives of \(\dot{x}\) and \(\dot{y}\) in Equation (10). If initial value \(\mathbf{X}_{0}=[x_{0},\ y_{0}]\), step \(h\), length of time \(T\), and total iteration \(N\) are given, then one gets chaotic sequence \(\mathbf{X}=[x,\ y]\) in the length of \(N\).  
**Step 2**: Remove pseudorandom sequence in \([0,t_{z}]\) before the MD system enters the chaotic attractor, and obtain pseudorandom sequence \(\mathbf{X}_{[t_{z},T]}\) after \(t_{z}\).  
**Step 3**: By moving the decimal point, removing integer parts, and taking absolute values, such as by multiplying the pseudorandom sequence by \(10^{\theta}\) (\(\theta\) is an integer), one gets  
\[\mathbf{S}^{\theta}=\left|\text{Floor}\left|\left(\mathbf{X}_{[t_{z},T]}\times 10^{ \eta}-\text{Floor}\left|\mathbf{X}_{[t_{z},T]}\times 10^{\eta}\right.\right| \right)\times 10^{\theta}\right.\right], \tag{20}\]  
where \"Floor\" is a function to take the integer part in the direction of negative infinity.  
Figure 9: (**a**) Bifurcation diagram with respect to parameter \(A\) of Poincare cross-section of MD System (16) when \(x=y\) and \(t>500\). (**b**) Lyapunov exponent spectra with respect to parameter \(A\) of MD System (16) when other parameters given in Equation (18).  
**Step 4**: Take a modular operation for pseudorandom sequence \(\mathbf{S}^{\theta}\) and convert it into binary sequence \(\mathbf{S}\), i.e.,  
\[\mathbf{S}=\text{Dec2 bin}\left(\text{Mod}\left(\mathbf{S}^{\theta},\;2^{\gamma}\right) \right), \tag{21}\]  
where \"Mod\" is a modulus function, \"Dec2 bin\" is a decimal-to-binary function, and \(\gamma\) is an integer.  
**Encryption 1: Scrambling Encryption**  
Information is encrypted by the scrambling encryption based on preprocessed pseudorandom sequence \(\mathbf{S}^{\theta}\).  
Sequences \(\mathbf{S}^{\theta}=[\mathbf{S}_{1}^{\theta},\mathbf{S}_{2}^{\theta}]\) are modeled by \(L\) (\(L\) is information length), and the new sequence or a pair of sequences is/are used as new position(s) to exchange the position of the original information, i.e., adjust the position of the original information as  
\[\mathbf{I}(i)\leftrightarrow\mathbf{I}(\mathbf{S}_{1}^{\theta}),\;\text{or}\;\mathbf{I}(i) \leftrightarrow\mathbf{I}(\mathbf{S}_{2}^{\theta}),\;\text{or}\;\mathbf{I}(i,\;j) \leftrightarrow\mathbf{I}(\mathbf{S}_{1}^{\theta},\;\mathbf{S}_{2}^{\theta}), \tag{22}\]  
where \(\mathbf{I}(0)\leftrightarrow\mathbf{I}(\text{end})\), or \(\mathbf{I}(0,\;0)\leftrightarrow\mathbf{I}(\text{end},\;\text{end})\).  
**Encryption 2: Chaos XOR Encryption**  
Transform information data \(\mathbf{I}\) into a binary sequence, and obtain encrypted information \(\mathbf{E}\) by  
\[\mathbf{E}=\mathbf{I}\oplus\mathbf{S}, \tag{23}\]  
where \(\oplus\) is the operation of XOR.  
On the receiving side, the decryption process is the inverse operation of above encryption algorithm, and the original information is successfully recovered with the correct keys.