# Two-Layer Security Algorithms to Prevent Attacks on Data in Cyberspace
## 3 Proposed Algorithm
### Data Encryption Process
If an attacker steals the static key, the attacker can decrypt each encrypted ciphertext with this static key, which is a problem. If a key is obtained from each plaintext, the length of which is equal to the length of the same plaintext, then the key equal to the plaintext cannot be snatched by any mechanism. An \"_EncryptedText Algorithm_\" was developed in this paper to derive a Vigenere key from the plaintext, as shown in Algorithm (1). ```
Input: Plaintext, Static Key Output: Ciphertext
1. Plaintext = [y], static key = [x]
2. Find the indexes [K\({}_{x}\)] of key [x] \[\left[x_{i}\right]=\left( \begin{array}{cccc}\left[x_{i0}\right]&\left[x_{i1} \right]&\left[x_{i2}\right]&\ldots\ldots&\left[x_{2n}\right]\\ \left\langle K_{0}\right]&\left[K_{1}\right]&\left[K_{2}\right]&\ldots\ldots& \left[K_{n}\right]\end{array} \right)\]
3.  nth indexes [K\({}_{i}\)] of static key [x]; \[\left[K_{i}\right]=\left[K_{0}\right]\left[K_{1}\right]\left[K_{2}\right] \ldots\ldots\ldots&\left[K_{n}\right]\]
4. Find the length (\(m\)) of static key [K\({}_{i}\)]. \[\left.m=\left[K_{i}\right]+1\right.\]
5. Find the indexes [\(T_{i}\)] of text [y] \[\left[y_{i}\right]=\left( \begin{array}{cccc}\left[y_{i0}\right]&\left[y_{i1 }\right]&\left[y_{i2}\right]&\ldots\ldots&\left[y_{2n}\right]\\ \left[T_{0}\right]&\left[T_{1}\right]&\left[T_{2}\right]&\ldots\ldots&\left[ KT_{n}\right]\end{array} \right)\]
6.  nth-Index [\(T_{i}\)] of text [y] \[\left[T_{i}\right]=\left[T_{0}\right]\left[T_{1}\right]\left[T_{2}\right] \ldots\ldots\ldots&\left[T_{n}\right]\]
7. Find the length (\(n\)) of text [\(T_{i}\)] \[\left.n=\left[T_{i}\right]+1\right.\]
8. Length equalization \[\left.I\text{ }F\left[K_{i}\right]\
eq\left[T_{i}\right]\text{, }THEN\text{ }repeat\text{ }[K_{i}]->\left[T_{i}\right]\text{ times}\]
9. Convert [\(K_{i}\)] and [\(T_{i}\)] index values into binary form. 10. XOR [\(T_{i}\)] with [\(K_{i}\)]. \[\left.Z_{\oplus\left[T_{0}\right]}=\left(\left[T_{0}\right]\oplus\left[K_{0} \right]\right)\left(\left[T_{1}\right]\oplus\left[K_{1}\right]\right)\ldots \ldots\ldots\left.\left(\left[T_{n}\right]\oplus\left[K_{n}\right]\right)\right.\] \[\left.Z_{\oplus\left[T_{i}\right]}=\oplus_{n}^{i=0}T_{i}\text{ }K_{i}\right.\]
11. Convert [\(Z_{\oplus\left[T_{i}\right]}\)] into decimal format [\(D_{[i]}\)]. \[\left.D_{[i]}=\left[D_{1}\right]\text{ }\left[D_{2}\right]\text{ }\left[D_{3}\right]\text{ }\ldots\ldots\ldots\text{ }\left[D_{n}\right]\]
12. Find \(GCD\) (\(\delta\)) of (\(m\)) and (\(n\)). \[\delta=GCD\) (\(m\), \[n\])
13. Obtain key (\(E_{[i]}\)) by adding \"\(\delta\)\" with [\(D_{[i]}\)]. \[\left.E_{[i]}=\left(D_{[1]}+\delta\right)\left(D_{[2]}+\delta\right)\left(D_ {[3]}+\delta\right)\ldots\left.\left(D_{[n]}+\delta\right)\right.\] \[\left.E_{[i]}=\left[E_{1}\right]\left[E_{2}\right]\text{ }\left[E_{3}\right]\text{ }\ldots\ldots\ldots\text{ }\left[E_{n}\right]\right.\] If \(E_{[i]}>25\) then \(E_{[i]}\)-24
14. Convert step 13 [\(E_{[i]}\)] values to equivalent ASCII characters [\(F_{[i]}\)]. \[\left.F_{[i]}=\left[F_{1}\right]\text{ }\left[F_{2}\right]\text{ }\left[F_{3}\right]\text{ }\ldots\ldots\ldots\text{ }\left[F_{n}\right]\right.\]
15. Convert step 11 [\(D_{[i]}\)] values to equivalent ASCII characters (\(I_{[2]}\)). \[\left.n=\left[T_{i}\right]+1\right.\]0
16. Apply the Vigenere cipher algorithm on [\({}_{[2]}\)] and F\({}_{[i]}\). 17. Obtain ciphertext (C). ```  
**Algorithm 1**Encrypption