# Two-Layer Security Algorithms to Prevent Attacks on Data in Cyberspace
## 4 Experiment
### Encryption Algorithm  
_Step 1:_ First, the _plaintext_ and a _static key_ are taken to encrypt the data. The _static key_ is represented with \"\([x_{i}]\)\", while the _text_ is represented with \"\([y_{i}]\)\", as shown in Equation (14) (Text and Key representation).  
\[[y_{i}]=\text{KEY5@CX}-98/\text{F} \tag{14}\]  
\[[x_{i}  
_Step 6:_ After determining the position of the _text_, all _indexes_ are written in the form of \"\([T_{i}]\)\", as shown in Equation (19) (Positions of Text).  
\[[T_{i}]=[75]\] [69] [89] [53] [64] [67] [88] [45] [57] [56] [47] [70]  
_Step 7._ To find the length of the _text_, all the indexes of \"\([T_{i}]\)\" are summed, and the \"\(n\)\" value is obtained, as shown in Equation (20) (Length of Texts).  
\[\text{Length of Text }(n)=12 \tag{20}\]  
_Step 8:_ After determining the length of the _key_ and _text_, the _lengths of key_ \"\([K_{i}]\)\" and _text_\"_ are equalized. If the lengths of \"\([K_{i}]\)\" and \"\([T_{i}]\)\" are equal, then go to step 9, and if the length of \"\([K_{i}]\)\" is less than \"\([T_{i}]\)\", then the length of \"\([K_{i}]\)\" is equal to \"\([T_{i}]\)\". The \"\([K_{i}]\)\" position is repeated \"\([T_{i}]\)\" times for length equalization, as shown in Figure 5.  
\[[\text{T}_{i}] = [75]\] [69] [89] [53] [64] [67] [88] [45] [57] [56] [47] [70] \[[\text{K}_{i}] = [\framebox{90}][64][114][33] [83] [72] [54] [53] [52] [90] [64] [114]  
_Step 9:_ After equalizing the lengths of \"\([K_{i}]\)\" and \"\([T_{i}]\)\", the \"\([K_{i}]\)\" and \"\([T_{i}]\)\" values are converted to 8-bit binary, as shown in Figure 6.  
_Step 10:_ The values of \"\([T_{i}]\)\" and \"\([K_{i}]\)\" obtained in step 9 are XORed by using the formula \"\(Z_{\oplus[i]}=([T_{n}]\oplus[K_{n}])\)\", as shown in Figure 7.  
_Step 11:_ The result obtained from \"\(Z_{\oplus[i]}\)\" is divided into _8-bit binary groups_ and then converted to decimal \"\(D_{[i]}\)\" form, as shown in Figure 8.  
Figure 5: Repetition of Key.  
Figure 6: binary conversion of text and Key.  
Figure 7: binary conversion of Text and Key.  
_Step 12:_ After obtaining different decimal values, the _GCD_ of _static key length (m)_ and _text length (n)_ is determined, as shown in Equation (21) (Eight-bit pairs of XOR result).  
\[\delta=GCD\] (9,12)  
\[\delta=3 \tag{21}\]  
_Step 13_: After obtaining the results of decimal \"\(D_{[i]}\)\" and _GCD (\(\delta\))_, the index of each \"\(D_{[i]}\)\" is accumulated with \"\(\delta\)\". The text cannot be decrypted without the Vigenere key. The Vigenere key is required to decrypt the text. Vigenere key results are represented by \"\(E_{[i]}\)\", as shown in Figure 9.  
_Step 14:_ All \"\(E_{[i]}\)\" values obtained in _step 13_ are converted to their _equivalent ASCII_, as shown in Figure 10. \"\(F_{[i]}\)\" is the _ASCII value_ of the Vigenere key.  
_Step 15:_ All \"\(D_{[i]}\)\" values obtained in _step 11_ are converted to their _equivalent ASCII_, as shown in Figure 11. \"\(I_{[i]}\)\" is an _encrypted text_ obtained from the proposed algorithm.  
_Step 16:_ Apply \"\(F_{[i]}\)\" and \"\(I_{[i]}\)\" results to the _Vigenere cipher algorithm_. The _Vigenere cipher table_ and implemented results of \"\(F_{[i]}\)\" and \"\(I_{[i]}\)\" are shown in Figure 12.  
Figure 11: Equivalent Text ASCII values.  
Figure 8: Eight-bit pairs of XOR result.  
Figure 10: Equivalent Key ASCII values.