# Two-Layer Security Algorithms to Prevent Attacks on Data in Cyberspace
## 3 Proposed Algorithm
### Data Encryption Process
\begin{table}
\begin{tabular}{c c} \hline \hline
**Symbol** & **Description** \\ \hline \([x_{i}]\) & Static key \\ \(m\) & Static key length \\ \([K_{i}]\) & Position of static keys \\ \([y_{i}]\) & Plaintext \\ \(n\) & Text length \\ \([T_{i}]\) & Position of text \\ \(\delta\) & GCD \\ \(Z_{\oplus[i]}\) & XOR result (encrypted text) \\ \(E_{[i]}\) & Vigenère Key \\ \(F_{[i]}\) & ASCII values of Vigenère key \\ \(I_{[i]}\) & ASCII values of encrypted text \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Mathematical Notations. division (GCD)_ to design a mechanism with the help of which the _Vigenere cipher_ can be obtained. To calculate the _GCD_, the \"\(\delta\)\" Equation (9) is used. \[\delta=GCD\;(m,n) \tag{9}\]  
The results of _GCD_ are represented by \"\(\delta\)\". To find the Vigenere key, the _GCD result \"\(\delta\)\"_ is added to _each index_ of _decimal values_ \"\(D_{[i]}\)\", as shown in Equation (10). \[E_{[i]}=(D_{[1]}+\delta)\;(D_{[2]}+\delta)\;(D_{[3]}+\delta)\ldots\;(D_{[n]}+\delta) \tag{10}\]  
\"\(E_{[i]}\)\" results are obtained by _adding_ the _GCD_ result \"\(\delta\)\" and \"\(D_{[i]}\)\" indexes, as shown in Equation (11). \[E_{[i]}\;=\;[E_{1}]\;[E_{2}]\;[E_{3}]\;\ldots\ldots\ldots\;\;[E_{n}] \tag{11}\]  
If any _index_ value of \"\(E_{[i]}\)\" is greater than 25, then the \"[\(E_{[i]}\)-24]\" formula is used. The range of alphabets used in this paper is _1 to 26_, starting from _index = 0 to index = 25_. After that, each \"\(E_{[i]}\)\" index element is converted to an _equivalent ASCII_ value, and a _text_ is obtained called Vigenere key. This _key_ is derived from the _text_ and works only in the _text_ that has been derived. Every Vigenere key of each _text_ is different. Vigenere key elements are represented by \"\(F_{[i]}\)\" indexes. As shown in Equation (12). \[F_{[i]}=[F_{1}]\;[F_{2}]\;[F_{3}]\ldots\ldots\ldots\;\;[F_{n}] \tag{12}\]  
\"\(D_{[n]}\)\" are the _nth elements_ of the Vigenere key. After obtaining the Vigenere key, an _encrypted text_ is obtained from the _decimal value_ \"\(D_{[i]}\)\" so that if the attacker tries to decrypt data using the _Vigenere cipher algorithm_, the attacker cannot access the original data. To obtain an _encrypted text_ from the _decimal text_ \"\(D_{[i]}\)\", every \"\(D_{[n]}\)\" letter should be converted to its _equivalent ASCII_, and the _encrypted text_ is obtained, as shown in Equation (13). \[I_{[z]}=[I_{1}]\;[I_{2}]\;[I_{3}]\ldots\ldots\ldots\;\;[I_{n}] \tag{13}\]  
\"\(I_{[z]}\)\" is the encrypted text obtained from the proposed algorithm. After that, _encrypted text_ \"\(I_{[z]}\)\" and Vigenere key \"\(F_{[i]}\)\" are implemented on the _Vigenere cipher algorithm_, and a _ciphertext_ will be obtained. The Vigenere cipher algorithm can be wholly secured using this proposed algorithm. If the attacker obtains a _static key_, the attacker cannot decrypt data due to this efficient algorithm. Key Management Process  
A static key is used to encrypt the data. A static key is a user-defined key that is the same for encryption and decryption. When the static key and plaintext are applied to the proposed algorithm, a Vigenere key is obtained. A Vigenere key is a plaintext-derived key that can be used in the same text from which it is derived. The key of one plaintext cannot be used in another plaintext. The Vigenere key derived from each plaintext is different from other plaintexts. Each plaintext-derived key works in the same plaintext from which it is derived. When the cipher value and the Vigenere key are derived from the plaintext, the cipher value depends on the Vigenere key, and the actual data are not retrieved without the Vigenere key. Both must be linked with each other to restore the data. Otherwise, the original data cannot be accessed. Whenever data are encrypted with one key and decrypted with two keys, it becomes impossible for an attacker to steal the two keys. Data are encrypted using a static key, which is a user-defined key. The Vigenere key is first used to decrypt the data, and then the static key can be used.