# Development of Security Rules and Mechanisms to Protect Data from Assaults
## 3 Proposed Algorithm
### Data Encryption Process
#### 3.2.4 Cipher Matrix Algorithm  
The cipher matrix algorithm is a technique in which each value is adjusted in tabular form. The cipher matrix algorithm defines a set of rules which is used to encrypt and decrypt the data.  
Figure 3: Encryption Process.  
_Rule 1:_ First, a pair of text values is created. After pairing, if any character in the text is left single, with no character present for the pair, then \"\(x\)\" will be appended with it, as shown in Figure 4.  
For example, a text \"_testing_\" is taken in which pairs of characters are created, and there is no character to pair with the last character, \"\(g\)\". Therefore, it is paired with \"\(x\)\" according to the rule.  
_Rule 2:_ If the two characters in the pair are the same, then each value will be separated and paired with \"\(x\)\". For example, in a pair \"zz\", each \"z\" will be separated and paired with \"x,\" such as \"\(zx\)\" and \"\(zx\)\", as shown in Figure 5.  
_Rule 3:_ If both pairs' characters are in the same table column. The characters will be replaced by the character below them in the encryption process. In contrast, in the decryption process, characters are replaced by their upper characters, as shown in Figure 6.  
_Rule 4:_ If both characters are in the same table row, in the encryption process, the characters will be replaced with the characters on their right side. If the character is in the last column, no character is on its right side. The character of the first column of the same row will be picked up, while in the decryption process, characters will be replaced with their left-side characters. If the character is in the last column, no character is on its left side, and then, the character will be replaced with the character of the first column of the same row, as shown in Figure 7.  
Figure 4: Completion of pairs.  
Figure 5: Pair completion of Duplicate Characters.  
Figure 6: Same column characters replacement.  
In Algorithm 1, first the plain text is taken, and each character of that plain text is converted to its equivalent ASCII. The different ASCII values of each plain text character are converted to an eight-bit binary. After obtaining different binary values, the bit-reversing mechanism is implemented on all binary values. The bit-reversing mechanism is implemented so that the values obtained from bit reversing are completely different from the plain-text values. The salting mechanism is implemented on the values obtained from the bit-reversing mechanism. In the salting mechanism, eight-bit binary values are taken, out of which a four-bit value is inserted in the start, and a four-bit value is be inserted in the end, and when pairing is done, all the data will be opposite to the plain text data. After that, the binary values are be converted to decimal form, and the Caesar cipher algorithm is applied to the decimal values. After implementing the Caesar cipher algorithm, the cipher matrix algorithm is implemented. The cipher matrix algorithm contains a set of rules that, if used efficiently, can completely protect the data from the attacker. After implementing the cipher matrix algorithm, a cipher text is obtained, and a key is implemented on this cipher matrix text. After implementing the key, the cipher XORation mechanism is implemented on the cipher matrix text, and a ciphertext is obtained.  
```
Input: Plain text Output: Cipher text
```
1. Convert each character to its equivalent ASCII.
2. Convert each ASCII value to an 8-bit binary.
3. Apply bit reversing in step 2.
4. Apply salting mechanism on bit-reversing results.
5. Convert salted binary values to decimals by making 8-bit pairs.
6. Apply the Caesar cipher algorithm on step 5.
7. Apply the cipher matrix algorithm on [PERSON]'s cipher results and obtain a cipher matrix text.
8. Obtain a user-defined key and apply the Cipher XORation mechanism on cipher matrix text.
9. Ciphertext. ```  
Figure 8: Replacement of character.  
Figure 7: Same-row characters replacement.