A Fast Text-to-Image Encryption-Decryption Algorithm for Secure Network Communication

: Data security is the science of protecting data in information technology, including authentication, data encryption, data decryption, data recovery, and user protection. To protect data from unauthorized disclosure and modiﬁcation, a secure algorithm should be used. Many techniques have been proposed to encrypt text to an image. Most past studies used RGB layers to encrypt text to an image. In this paper, a Text-to-Image Encryption-Decryption (TTIED) algorithm based on Cyan, Magenta, Yellow, Key/Black (CMYK) mode is proposed to improve security, capacity, and processing time. The results show that the capacity increased from one to four times compared to RGB mode. Security was also improved due to a decrease in the probability of an adversary discovering keys. The processing time ranged between 0.001 ms (668 characters) and 31 s (25 million characters), depending on the length of the text. The compression rate for the encrypted ﬁle was decreased compared to WinRAR. In this study, Arabic and English texts were encrypted and decrypted.


Introduction
Sensitive information in the form of text, pictures, audio, and video are exchanged over communication systems. Cryptography is the application of techniques for encrypting data between the sender and receiver so that the receiver can read the data and an adversary cannot. Making sensitive data safe is critical with the overwhelming dependence on electronic communication systems in the modern world. Data may be transferred without the danger of being intercepted by employing several cryptographic procedures [1][2][3][4]. Encryption is the most common way to protect large amounts of text data [5]. Cryptography is a process to convert plain text into cipher using two types of key; symmetric and asymmetric key. Symmetric means that the same key is used between sender and receiver in encryption and decryption processes. The examples of symmetric keys are substitution, transposition, hill cipher, Play fair cipher, Vigener, and others. While asymmetric key means that there are two keys in encryption and decryption processing-a private and public key [6][7][8]. Figures 1 and 2 illustrate the block diagram of the cryptography asymmetric and symmetric keys, respectively. Many approaches, such as Advanced Encryption Standard (AES), Data Encryption Standard (DES), Rivest-Shamir-Adleman (RSA), Triple Data Encryption Standard (3-DES) and other established procedures, are used to encrypt and decrypt data [9][10][11]. However, these approaches are still ineffective at encrypting large-scale text with high redundancy and large storage capacities. To alleviate these issues, researchers have developed various text-to-image encryption algorithms to increase text security and efficiency, thus improving robust cryptographic algorithms.
In this work, there are two concepts of image encryption, color mode and color code, that need to be considered in data encryption. Color mode encoding is a group of different colors that are mixed to obtain the color required to display the image on the screen or

CMYK Color System RGB Color System Grayscale Color System Binary Color System
This system consists of 4 channels cyan, magenta, yellow, and black This system consists of 3 channels red, blue, and green This system consists of only one channel gray Each pixel in this system is black or white The size of the pixel is 32 bits The size of the pixel is 24 bits The size of the pixel is 8 bits The size of the pixel is 1 bit The number of colors available is 2 32 The number of colors available is 2 24 The number of colors available is 2 8 The number of colors available is 2 0 preferable to use in printers preferable to use on display screens preferable to use in image processing preferable to use in image processing   This paper presents the CMYK color system to increase the security and capacity of the number of encrypted characters and decrease the size of the encrypted file.
The rest of this paper is arranged as follows: Section 2 presents the related works and mentions the limitations of former works. Section 3 describes the system framework. Section 4 shows the experimental results and analyzes the results obtained. Section 5 shows a discussion of the results and study advantages and limitations. Finally, the conclusion and future research directions are provided in Section 6.

Related Work
Researchers in the digital data field are continuously seeking to develop new robust encryption methods to secure private material, either by combining current techniques or by developing new techniques to protect text, image, audio, and video. Some attempts have recently followed the path of encrypting some types of data so as to transform them into another sort of data, such as text-to-image, text-to-audio, audio-to-image, and so on. For example, the text to image encryption algorithm (TTIE) was proposed in [14] which This paper presents the CMYK color system to increase the security and capacity of the number of encrypted characters and decrease the size of the encrypted file.
The rest of this paper is arranged as follows: Section 2 presents the related works and mentions the limitations of former works. Section 3 describes the system framework. Section 4 shows the experimental results and analyzes the results obtained. Section 5 shows a discussion of the results and study advantages and limitations. Finally, the conclusion and future research directions are provided in Section 6.

Related Work
Researchers in the digital data field are continuously seeking to develop new robust encryption methods to secure private material, either by combining current techniques or by developing new techniques to protect text, image, audio, and video. Some attempts have recently followed the path of encrypting some types of data so as to transform them into another sort of data, such as text-to-image, text-to-audio, audio-to-image, and so on. For example, the text to image encryption algorithm (TTIE) was proposed in [14] which converted each letter in a text file into the RGB of a single pixel in an image to create a matrix. Then, it switched operations on the columns to make things more difficult for the attacker. Thus, the attacker must attempt 256 3 26 for text analysis in this approach, which takes a long time. In another example, Abusukhon et al. [15] proposed an encryption technique, called text-to-image encryption, based on the Diffie-Hellman (DH) key-exchange protocol to create an identical key (represented as a collection of RGB pixels) on both sides (client and server). The limitation of these studies [14][15][16] is that the hacker can know the number of letters in the main text, as shown in Figure 4. converted each letter in a text file into the RGB of a single pixel in an image to create a matrix. Then, it switched operations on the columns to make things more difficult for the attacker. Thus, the attacker must attempt 256 for text analysis in this approach, which takes a long time. In another example, Abusukhon et al. [15] proposed an encryption technique, called text-to-image encryption, based on the Diffie-Hellman (DH) key-exchange protocol to create an identical key (represented as a collection of RGB pixels) on both sides (client and server). The limitation of these studies [14][15][16] is that the hacker can know the number of letters in the main text, as shown in Figure 4. Another study by Talib et al. [17] proposed a white-page image encryption algorithm (WPI) to improve security and make it difficult for hackers to guess the key, misleading them to also believe that the text message had no information. Their study employed the range 246 to 255 to construct varying densities of white pixels; however, the disadvantage of this work was that the color space was very small, comprising only nine colors from 246 into 255.
Another encryption method was proposed by Smita et al. [18]. This method was based on the cell division that happens in living organisms to encode a text message into a picture. Both the transmitter and receiver keep an image database to utilize in the encryption process. A picture was chosen to be encrypted with the message depending on the time of day. The R, G, and B values were extracted to get a total of three "chromosomes", and then the three acquired vectors were split into an equal number of chromosomes ('n' from each R, G, and B). Three vectors, one from each of R, G, and B, were chosen and XOR'ed together, reducing 3n to n, and converting the vectors above to DNA sequences. The coding schemes 00-A, 01-T, 10-G, and 11-C were used.
Another study [19] presented a pixel-based text-to-image encryption technique using three stages, including associative memory, text-to-image encryption, and image analysis based on memory and data size. In the first stage, a group of nine characters was created. If the number was not a multiple of nine, additional spaces were added. Then, for each character, an ASCII code was generated. To display the text, the viewer must first split the picture into blocks. A secret key would be used to change each color component. This technique might be applied to a vast number of databases.
Another method for text-to-image encryption and decryption based on piece-wise linear chaotic maps was suggested by [20,21]. This work presented a piece-wise linear chaotic map approach for encrypting text into images (PWLCM). The suggested technique may take a text file as input and transform it into a cipher picture, which could then be decrypted. This method had the benefit of being highly secure and difficult to breach. PWLCM Maps were the simplest of the chaotic maps. The text was first transformed from Another study by Talib et al. [17] proposed a white-page image encryption algorithm (WPI) to improve security and make it difficult for hackers to guess the key, misleading them to also believe that the text message had no information. Their study employed the range 246 to 255 to construct varying densities of white pixels; however, the disadvantage of this work was that the color space was very small, comprising only nine colors from 246 into 255.
Another encryption method was proposed by Smita et al. [18]. This method was based on the cell division that happens in living organisms to encode a text message into a picture. Both the transmitter and receiver keep an image database to utilize in the encryption process. A picture was chosen to be encrypted with the message depending on the time of day. The R, G, and B values were extracted to get a total of three "chromosomes", and then the three acquired vectors were split into an equal number of chromosomes ('n' from each R, G, and B). Three vectors, one from each of R, G, and B, were chosen and XOR'ed together, reducing 3n to n, and converting the vectors above to DNA sequences. The coding schemes 00-A, 01-T, 10-G, and 11-C were used.
Another study [19] presented a pixel-based text-to-image encryption technique using three stages, including associative memory, text-to-image encryption, and image analysis based on memory and data size. In the first stage, a group of nine characters was created. If the number was not a multiple of nine, additional spaces were added. Then, for each character, an ASCII code was generated. To display the text, the viewer must first split the picture into blocks. A secret key would be used to change each color component. This technique might be applied to a vast number of databases.
Another method for text-to-image encryption and decryption based on piece-wise linear chaotic maps was suggested by [20,21]. This work presented a piece-wise linear chaotic map approach for encrypting text into images (PWLCM). The suggested technique may take a text file as input and transform it into a cipher picture, which could then be decrypted. This method had the benefit of being highly secure and difficult to breach. PWLCM Maps were the simplest of the chaotic maps. The text was first transformed from 7-bit ASCII to its double counterpart, and then padding was performed to provide the appropriate matrix for the image to which the text would be converted. The matrix bits were then permuted, and diffusion occurring in two steps, first for the rows and subsequently for the columns. Finally, the PWLCM map was used for both permutation and diffusion. However, the length of encrypted characters in file text was small, and the time required for encrypting and decrypting were not considered.
This study proposes a fast TTIED algorithm depending on the CMYK mode where the number of layers increases, the capacity of the characters to be encrypted increases, and the compression rate for encrypted-decrypted files decreases. Moreover, the number of colors available is increased to 4,294,967,295 instead of 16 million characters in prior studies. The total number of keys utilized has now risen to four. The processing time was sped up, leading to an increase in encryption strength and capacity.

System Framework
In this work, CMYK mode was proposed to use in the text to image encryption algorithm. CMYK is widely used in printers because it has several advantages to display images clearly and in colors that are close to what is perceived as true.
This mode consists of four layers-CMYK. This can increase the number of characters that are loaded to each pixel in each layer, and thus the capacity becomes four times that of previous studies. Only four keys are used. This implies that depending on the programmer, eight keys per layer can use two keys, or 16 keys per layer can use four keys.
Some of the definitions used for explaining the proposed TTIED algorithm are listed below: • Plaintext (PT): Is the original text to be encrypted; this text is input by the sender (user).

•
Length of plaintext or secret text (ST length): It is necessary to know the number of characters in the original text because the resulting image in this work is directly proportional to the size of the text (the number of letters). One of the advantages of this work is that the smaller the text size, the smaller the image size. In this way, the efficiency of the algorithm increases in terms of encryption strength and saving of storage space. • Encryption image or cipher text (EI): The encrypted image, which is the image resulting from this algorithm after the letters were converted to the color in the image, is CMYK mode, not RGB mode, as each pixel in the image carries four letters.

•
Size of encrypted image (EI size): The decryption process depends mainly on the size of the encrypted image received by the recipient through the size of the image, and after several calculations are made on the image, the encrypted text is extracted based on the following equations: where Equation (1) is to find the size of image encryption and Equation (2) is for the text size that is proportional to the dimensions of the image encryption.
The key is used in the en/decryption algorithm to obtain the original text. By default, four keys were used in this paper, each layer has its own key, and as previously mentioned, it is possible to use several keys according to the programmer's desire. Each letter takes a color, in CMYK this is a 32 bit number of four possible colors with 256 levels each. The first key is for Layer 1 (cyan), the second key is for Layer 2 (magenta), the third key is for Layer 3 (yellow), and the fourth key is for Layer 4 (black). All keys are entered by the sender according to the language to be encrypted: English, Arabic, Hindi or any other language. This is one of the advantages of this work. It is also possible to encrypt a text consisting of letters in various languages. In this work, four keys were used; each key was 37 characters long.
The schematic diagram of the proposed method and the flowchart that shows the main steps of the TTIED algorithm based on CMYK are shown in Figures 5 and 6, respectively.
Arabic, Hindi or any other language. This is one of the advantages of this work. It is also possible to encrypt a text consisting of letters in various languages. In this work, four keys were used; each key was 37 characters long.
The schematic diagram of the proposed method and the flowchart that shows the main steps of the TTIED algorithm based on CMYK are shown in Figures 5 and 6, respectively.

Our Experiments
All experiments were carried out using Python on a computer with an Intel Core I7 2.6G Hz CPU, 8 GB of RAM, and 64-bit Windows 10 operating system. Table 2 illustrates the proposed work with different lengths of text, dimensions, number of keys, types and sizes of the images. The encrypted images of the proposed algorithm for different lengths of text from 668 into 25 million characters are shown in Figure 7.

Histogram Analysis
The histogram of the ciphered image should be significantly different from the histogram of the plain image, and the histogram of the ciphered image should be as uniformly distributed as possible, which means that the probability of the existence of any color scale value is the same, and it is totally random [22][23][24]. Figure 8 shows the histogram of plain text, and Figure 9 shows the ciphertext for different text lengths.

Histogram Analysis
The histogram of the ciphered image should be significantly different from togram of the plain image, and the histogram of the ciphered image should b formly distributed as possible, which means that the probability of the existen color scale value is the same, and it is totally random [22][23][24]. Figure 8 shows gram of plain text, and Figure 9 shows the ciphertext for different text lengths.

Information Entropy (IE) Analysis
Information Entropy (IE) measures the average amount of information per bit in an image. It provides all of the information that is accessible in the image. Every pixel has a unique value. As a result, the entropy of an encrypted image denotes that each pixel has a uniform probability distribution [25,26]. It is calculated as follows: where E(X) denotes the message source's entropy (X). The probability of occurrence of Xi is denoted by P(Xi). { 0-8 } is the value of IE. For an 8-bit image, it should be close to 8.
The higher the value of information entropy, the more randomness that may be achieved at the pixel level. All experiments showed entropy 1-5. In this study, the entropy depends on the size of the file; when the length of text increases, the entropy is increased, as shown in Table 3.

Key Space (KS) Analysis
Security keys are an important element of every encryption technique since the algorithm's strength is dependent on them. The keys should be able to withstand any form of attack. Large keyspace and high sensitivity are desired qualities of robust secret keys [30][31][32].
In this work, the attacker requires a lot of time to find the key, and the reason for this is that each pixel is produced by a mixture of four layers, so it carries four letters. The number of colors is 2 32 , then the number of possibilities to find the key can be found as x , where x is the number of characters used, y is the number of layers, and z is the number of colors available.

Information Entropy (IE) Analysis
Information Entropy (IE) measures the average amount of information per bit in an image. It provides all of the information that is accessible in the image. Every pixel has a unique value. As a result, the entropy of an encrypted image denotes that each pixel has a uniform probability distribution [25,26]. It is calculated as follows: where E(X) denotes the message source's entropy (X). The probability of occurrence of Xi is denoted by p(xi). { 0-8 } is the value of IE. For an 8-bit image, it should be close to 8.
The higher the value of information entropy, the more randomness that may be achieved at the pixel level. All experiments showed entropy 1-5. In this study, the entropy depends on the size of the file; when the length of text increases, the entropy is increased, as shown in Table 3. Table 3. Information entropy for encrypted images.

Key Space (KS) Analysis
Security keys are an important element of every encryption technique since the algorithm's strength is dependent on them. The keys should be able to withstand any form of attack. Large keyspace and high sensitivity are desired qualities of robust secret keys [30][31][32].
In this work, the attacker requires a lot of time to find the key, and the reason for this is that each pixel is produced by a mixture of four layers, so it carries four letters. The number of colors is 2 32 , then the number of possibilities to find the key can be found as x y z , where x is the number of characters used, y is the number of layers, and z is the number of colors available.
In the process of encryption and decryption, we need the English letters (a-z), numbers (0-9) and space, a total of 37 characters, as shown in Table 4. The number of key possibilities can then be calculated by 37 4 2 32 and equal to (37 2.40758753348 × 10 2585827972 ). The number of key possibilities of the proposed TTIED-CMYK algorithm compared to the most similar related studies is shown in Table 5. Table 5. A comparison of the number of key possibilities of the proposed algorithm compared to the most related studies.

Methods The Number of Possible Key Possibilities
Ref. [ It is clear from Table 5 that the number of key possibilities when using 256-character ASCII key is calculated by 256 42 32 and equal to 256 2.40758753348 × 10 2585827972 .

Key Sensitive Analysis
Efficient and robust encryption should have a high sensitivity to its secret key, meaning that even slight changes in the secret key should result in totally different cipher images. Moreover, with a slightly changed key, the method must be impossible to decrypt a cipher image or obtain some plain text patterns [34][35][36][37][38][39]. This is particularly useful for defending against brute force attacks. In this paper, there are four keys, each key consists of 37 or 256 bytes. In this test, applied 37 bytes, the total key size is 148 bytes. The encrypted image is decrypted using four slightly different test keys to examine the key sensitivity of our proposed technique. The plaintext is "This text to test TTIED-CMYK Mode Algorithm". The results presented in Table 6 show the influence of minor changes to key.

Time and Capacity Analysis
Many parameters affect the speed of an algorithm, including the CPU's specifications and structure, memory capacity, text size, software used, and so on. The time required to convert the text to image algorithm is known as execution time. It is the sum of the compile and run times. The execution time should be minimum for the practical implementation of text-to-image encryption. It is generally measured in seconds, milliseconds, or minutes [40]. The image was processed on a layer-by-layer basis, which improved the speed. The capacity was four times compared with others. Table 7 shows that the suggested algorithm is exceptionally fast, and the processing time was from 1 micro to 31.01 sec depending on the length of text, as shown in Table 7 and Figure 10. Table 6. The key sensitivity of the proposed algorithm with slightly changed key.

Key Cipher Text Plaintext
Decryption with the correct key meaning that even slight changes in the secret key should result in totally different cipher images. Moreover, with a slightly changed key, the method must be impossible to decrypt a cipher image or obtain some plain text patterns [34][35][36][37][38][39]. This is particularly useful for defending against brute force attacks. In this paper, there are four keys, each key consists of 37 or 256 bytes. In this test, applied 37 bytes, the total key size is 148 bytes. The encrypted image is decrypted using four slightly different test keys to examine the key sensitivity of our proposed technique. The plaintext is "This text to test TTIED-CMYK Mode Algorithm". The results presented in Table 6 show the influence of minor changes to key.

Time and Capacity Analysis
Many parameters affect the speed of an algorithm, including the CPU's specifications and structure, memory capacity, text size, software used, and so on. The time required to convert the text to image algorithm is known as execution time. It is the sum of the compile and run times. The execution time should be minimum for the practical implementation of text-to-image encryption. It is generally measured in seconds, milliseconds, or minutes [40]. The image was processed on a layer-by-layer basis, which improved the speed. The capacity was four times compared with others. Table 7 shows that the suggested algorithm is exceptionally fast, and the processing time was from 1 micro to 31.01 sec depending on the length of text, as shown in Table 7 and Figure 10.

Application Program of TTIE_CMYK Mode
To make it easier for the user to use, the code has been converted into an application program called TTIE_CMYK mode with the extension .exe in the Python language, as shown in Figure 11.

Comparison Our Work with Previous Studies
TTIED-CMYK is proposed in this work to improve security and increase the capacity of the number of characters in TTIED-CMYK image. Figure 12 clears the proposed work and previous studies in terms of number of layers, number of keys, type of mode-CMYK and RGB. It is clear that our proposal is better than others. The number of keys is increased with mode type CMYK. Table 8 shows the comparison between CMYK and RGB mode.

Application Program of TTIE_CMYK Mode
To make it easier for the user to use, the code has been converted into an application program called TTIE_CMYK mode with the extension .exe in the Python language, as shown in Figure 11.

Comparison Our Work with Previous Studies
TTIED-CMYK is proposed in this work to improve security and increase the capacity of the number of characters in TTIED-CMYK image. Figure 12 clears the proposed work and previous studies in terms of number of layers, number of keys, type of mode-CMYK and RGB. It is clear that our proposal is better than others. The number of keys is increased with mode type CMYK. Table 8 shows the comparison between CMYK and RGB mode.     Figure 13 shows the comparison between the proposed algorithm and QR related to the capacity. It is clear that the capacity is increased in TTIED-CMYK according to the following equation.

Capacity and File Size Comparison
Capacity length width no. of channels (4) No. of channels to CMYK equals four. Dimension of QR code version 40 equal 177 177. The maximum capacity is ~30,000 bytes [44,45]. However, CMYK mode takes the same size as the QR code. Thus,   Figure 13 shows the comparison between the proposed algorithm and QR related to the capacity. It is clear that the capacity is increased in TTIED-CMYK according to the following equation. Capacity = length × width × No.of channels (4) No. of channels to CMYK equals four. Dimension of QR code version 40 equal 177 × 177. The maximum capacity is 30,000 bytes [44,45]. However, CMYK mode takes the same size as the QR code. Thus, the capacity 177 × 177 × 4 equals~125,000 bytes. Figure 13. The capacity comparison between the proposed work and WINRAR in term  Figure 14 shows the file size comparison between the proposed algorithm and WIN-RAR. Two experiments were carried out. The first test was to reduce the size of the image from 18 KB with WinRAR to 7 KB with TTIE-CMYK. Secondly, the size of the image was decreased from 26 KB with WinRAR to 10 KB with TTIE-CMYK.

Discussion
In this paper, the proposed TTIED-CMYK algorithm was shown to be useful in several applications, such as wireless sensor networks and the internet of things (IoT). The proposed algorithm has a high encryption strength in terms of the number of keys, the size of each key, and high capacity at different aspects, such as the size of text, the number of keys, and the execution time. It opens a platform for academics to investigate ways to improve the speed of the text-to-image algorithm, as well as increasing storage capacity, as the algorithm does not require much storage space, and security, as the algorithm provided a high level of protection. The proposed algorithm also has random behavior and extremely fast computations in comparison with previous studies. The key size is 148 or 1024 bytes, and it has a large secret key (4 keys; each key size is 37 or 256 bytes). However, TCP transmission is required; therefore, it is preferably used in e-mail, and key exchange is required.

Conclusions
This paper introduces the TTIED-CMYK algorithm to improve security, capacity, and processing time. CMYK mode consists of four layers; Cyan, Magenta, Yellow, and Black. The results were produced using the Python language and showed that capacity increased from 1 to 4 times compared with RGB mode, defining improvement as being based on the probability of finding keys. The processing time range was between 0.001 ms for 668 characters and 31 s for 25 million characters depending on the length of text. Both Arabic and English languages were encrypted and decrypted in this study, and there was no constraint on the language of the input text. In TTIED-CMYK mode, in this scenario, the capacity was 125,000 bytes (characters) compared to QR codes which are~30,000 bytes (characters), and the file size was reduced by 7 KB compared to the WinRAR archive, which was 18 KB. The key combinatorial space was increased, as shown in Tables 4 and 5. This proposed method gives good results compared to previous work. In future work, we recommend using plain text sensitivity, image to image encryption to validate CYMK with NPCR and UACI tests, and the Chi-squared test.