As mentioned, the data encryption section is divided into four layers, and each layer performs operations related to encryption, and each layer transfers data from the upper layer to the lower layer.
3-1) INSERT GAP TEXT LAYER
The first layer adds useless data to useful data, this layer helps to insert and add a lot of useless data to useful data. Although here with a simple example and using the GapText variable, the useless data is inserted and added to the useful data.
Using the choice function in the random library, a short sentence is created, this is the useless data in the GapText variable, and it is displayed in the monitor output as shown in (Figure 4).
GapText = ", "+ random.choice(MyDictionary6)+" "+random.choice(MyDictionary4)+" "+random.choice(MyDictionary8)+" "+random.choice(MyDictionary9)+" ..."
The two print functions set the text color to yellow and the background color to red, mostly displayed for the informative aspect of the GapText variable.
print(colorama.Fore.RED+colorama.Back.YELLOW+colorama.Style.BRIGHT+" Gap Text : "+GapText)
The replace function of the MyData variable helps to combine and add the useless data in the GapText variable with the useful data of the MyData variable, the same operation of inserting the useless data into the useful data is done.
MyData=MyData.replace("...",GapText)
MyData variable displays useless data and useful data in the output using the print function.
Print(MyData)
The split function of the MyData variable separates the words from each other by using the space letter, and the words are placed in the MyDataList variable, which is of the list type.
MyDataList=MyData.split(" ")
The sleep function from the time library creates a delay using the duration variable, and then after this delay it enters the next stage of the algorithm and the second layer starts to run, in the following layers in the main code of this algorithm from the following code line Used.
time.sleep(duration)
3-2) HIDE TEXT LAYER
This layer performs the act of hiding and replacing useless data with useful data, this action helps to protect the data more.
According to (Figure 5), the output of this layer is displayed and the algorithmic implementation of this layer is that the ElementCounter variable counts the words processing useful data and useless data. The first for loop scrolls the list of words, and for each word selected, one unit is added to the ElementCounter variable. The second for loop for the length of the dictionary of the first replacement words, if the word in the list of useful data and useless data is equal to the data list of the first dictionary, a word is randomly selected from the first dictionary using the choice function. The selected word in the list of useful data and useless data and the randomly selected word using the choice function will be placed in the variables of the first position of the dictionary in the choice variable. Then the chosen random word is replaced using the choice variable in the MyDataList variable.
ElementCounter=-1
for element in MyDataList:
ElementCounter=ElementCounter+1
for i in range(0,len(MyDictionary1)):
if element == MyDictionary1[i]:
choice = random.choice(MyDictionary1)
MyDictionaryPosition1_1.append(element)
MyDictionaryPosition2_1.append(choice)
MyDataList[ElementCounter] = choice
As you can see, the next block of code repeats the same routine but instead includes the length of the second dictionary variable and the position variable of the second dictionary. By using variable i, like the previous block, words are replaced in MyDataList variable.
ElementCounter=-1
for element in MyDataList:
ElementCounter=ElementCounter+1
for i in range(0,len(MyDictionary2)):
if element == MyDictionary2[i]:
choice = random.choice(MyDictionary2)
MyDictionaryPosition1_2.append(element)
MyDictionaryPosition2_2.append(choice)
MyDataList[ElementCounter] = choice
Next, according to the two loops, the third dictionary variable and the third dictionary position variables also navigate the list of useful data and useless data. The act of replacing nouns, subjects, adverbs of time, adverbs of place, etc., using the ElementCounter variable for the MyDataList variable is performed by the randomly selected word of the choice variable using the choice function. The fourth, fifth, and tenth dictionaries perform the replacement of useful data and useless data, and these replacements cause useful data and useless data to be replaced with completely useless data.
ElementCounter=-1
for element in MyDataList:
ElementCounter=ElementCounter+1
for i in range(0,len(MyDictionary3)):
if element == MyDictionary3[i]:
choice = random.choice(MyDictionary3)
MyDictionaryPosition1_3.append(element)
MyDictionaryPosition2_3.append(choice)
MyDataList[ElementCounter] = choice
The for loop for the variable MyDataList is used to show the replacement of useful data and useless data with completely useless data, this layer helps to make useful data completely useless and completely hidden and inaccessible.
for element in MyDataList:
print(element, end=” “)
3-3) INSERT ENCRYPTION RANDOM LAYER
The third layer encrypts completely useless data and turns it into non-English data, Ascii codes can be used to perform encryption (Level 1 in Figure 1).
Totally useless data should be converted from words in the MyDataList variable from a list type to a string, so using the source variable, the process of converting the list to a string is done.
For element in MyDataList:
source= source + element + " "
After converting and creating string, completely useless data, using the randint function from the random library, a random number is selected between zero and fifty. Due to the existence of the for loop and the value of zero to the maximum length of max_len numbers, random numbers are generated and added to the key_random_list variable.
for i in range(0, max_len):
key_random_list.append(random.randint(0,50))
Using the print function, completely useless data strings are displayed in the output.
print(" Text : " + source)
The for loop helps to sum each character in the completely useless source data string, using the ord function, the ASCII codes of the key_random_list variable with a random number. The sum of these two numbers creates a new random character using the chr function, and each new random character that is encrypted is added and pasted with the encrypt variable. If index, which is the length of the string, is equal to the length of the maximum random number max_len, index will be zero again and the list of random numbers will be used again. If the length of the encrypted string is equal to the index variable using the len function, it means that the entire string of useless data has been scrolled and encrypted, and it is exited from the for loop. Of course, every time a character from the completely useless string is checked, one unit is added to the index and the initial value of the index variable is zero.
index=0
For char in source:
if(index==max_len):
index=0
encrypt+=chr(ord(char)+key_random_list[index])
if(index==len(source)):
break
index+=1
At the end of this layer, according to (Figure 6), using the print function, the encrypted string value is displayed in the output in the format of step one.
print(" Encrypt : " + encrypt)
3-4) INSERT ENCRYPTION GAP LAYER
This layer helps to encrypt more and more useless data, the more useless data is encrypted, the harder and harder it is to discover useful data (Level 2 in Figure 1).
Using the print function, the encrypted string value is displayed in the output in the format of step one.
print(“ encrypt : “)
print(encrypt)
The encrypt_gap variable can be initialized empty or with some junk data. Of course, if initialization is done with junk data, the junk data will be shown next to the encrypted data in the format of step one. My preference is to use the encrypt_gap variable with an empty value.
#encrypt_gap=" 1234567890 "
encrypt_gap=""
Again, using the randint function from the random library, a random number is selected between the numbers zero to fifty, and due to the existence of the for loop and the value of zero to the maximum length of max_len numbers, random numbers are generated and added to the key_random_list2 variable.
for i in range(0,max_len):
key_random_list2.append(random.randint(0,50))
Again, the for loop helps that every single character in the encrypted data string is added in the format of the first step of encrypt, using the ord function, the ASCII codes of the variable key_random_list2 with a random number. The sum of these two numbers creates a new random character using the chr function, and each new random character that is re-encrypted is appended with the encrypt_gap variable. If index, which is the length of the string, is equal to the length of the maximum random number max_len, the value of index will be zero and the list of random numbers will be used again. If, using the len function, the length of the encrypted string is equal to the index variable, that means the entire encrypted data string of step one has been scrolled and re-encrypted and exits the for loop. Of course, every time a character from the coded string is checked in step one format, one unit is added to the index and the initial value of the index variable is zero.
index=0
for char in encrypt:
if(index==max_len):
index=0
encrypt_gap+=chr(ord(char)+key_random_list2[index])
if(index==len(encrypt_gap)):
break
index+=1
Using the print function, the value of the encrypted string of the second step is displayed in the output.
print(" encrypt_gap : ")
print(encrypt_gap)
The amount of encrypted data in the format of the second step in the encrypt_gap variable is set into the encrypt_gap_send_message variable.
encrypt_gap_send_message = encrypt_gap
Finally, according to (Figure 7) in this layer, the amount of encrypted data can be sent in the format of the second step, in the network platform, and the sending message is displayed in red. The encrypt_gap_send_message variable is displayed with the encrypted data in the second step format.
print(colorama.Fore.RED+ " Send Message : ")
print(encrypt_gap_send_message)