A Modified AES Based Algorithm for Text to Image Encryption Using Combination of RGB Substitution Technique

Muzammil Ahmed
7 min readAug 26, 2021

Abstract — Network security works on the principle of Encryption and Decryption. Every security algorithm is made up of the use of a secret key which is responsible to Encrypt data in some unreadable type of message or changes original data into different data. In this paper, we have given a novel approach that transforms a text file into an image using RGB substitution hence an intruder will be confused, whether the actual data to be transmitted is a text or an image. Further, it also undergoes an AES encryption stage which encrypts the generated image, and we add a keystream generator (A5/1, W7) to AES to ensure improving the encryption performance; mainly for images characterized by reduced entropy. The implementation of both techniques has been realized for experimental purposes. The encryption and decryption phenomenon makes use of a combination database for the transformation of text into image.

Keywords — Cryptography, Encryption, Advanced Encryption Standard (AES), keystream generator.

I. INTRODUCTION

This article is divided into the following four sections; in section I, we presented the basic introduction of the AES Algorithm, in section II, a keystream generator has been presented, section III discusses the proposed model analysis, and finally section V concludes the paper.

II. AES ALGORITHM

Rijndael is a block cipher developed by Joan Daemen and Vincent Rijmen. The algorithm is flexible in supporting any combination of data and key size of 128, 192, and 256 bits. However, AES merely allows a 128-bit data length that can be divided into four basic operation blocks. These blocks operate on an array of bytes and are organized as a 44 matrix that is called the state. For full encryption, the data is passed through Nr rounds (Nr = 10, 12, 14) [4, 6]. These rounds are governed by the following transformations:

Fig. 1. Basic Structure of AES Algorithm

A. Bytesub transformation:
Is a non-linear byte Substitution, using a substation table (s-box), which is constructed by multiplicative inverse and affine transformation. Fig.1 shows the step of the Bytesub transformation.

B. Shiftrows transformation:
Is a simple byte transposition, the bytes in the last three rows of the state are cyclically shifted; the offset of the left shift varies from one to three bytes.

C. Mixcolumns transformation:
Is equivalent to a matrix multiplication of columns of the states. Each column vector is multiplied by a fixed matrix. It should be noted that the bytes are treated as polynomials rather than numbers.

D. Addroundkey transformation:
Is a simple XOR between the working state and the round key. This transformation is its own inverse.

The encryption procedure consists of several steps. After an initial add round key, a round function is applied to the data block (consisting of byte sub, shift rows, mix columns and add round key transformation, respectively). It is performed iteratively (Nr times) depending on the key length. The decryption structure has the same sequence of transformations as the one in the encryption structure. The transformations Inv-Bytesub, the Inv-Shiftrows, the Inv-Mixcolumns, and the Addroundkey allow the form of the key schedules to be identical for encryption and decryption.

III. KEY STREAM GENERATOR

A. A5/1 Key Stream Generator:
The A5/1 cipher is composed of three Linear Feedback Shift Registers (LFSRs); R1, R2, and R3 of length 19, 22, and 23 bits, respectively. Each LFSR is shifted, using clock cycles that are determined by a majority function. The majority function uses three bits; C1, C2, and C3. The 64 bits of the keymap to the LFSRs initial state as: R1(19 bits): x19 + x5 + x2 + x + 1 , R2(22 bits): x22 + x +1,R3(23 bits): x23 + x15 + x2 + x + 1. At each clock cycle, after the initialization phase, the last bits of each LFSR are XORed to produce one output bit [2, 8].

B. W7 Key Stream Generator:
The W7 algorithm is a byte-wide, synchronous stream cipher optimized for efficient hardware implementation at very high data rates. It is a symmetric key algorithm supporting key lengths of 128 bits. W7 cipher contains eight similar models; C1, C2,., C8. Each model consists of three LFSRs and one majority function. W7 architecture is composed of a control unit and a function unit [8].

Fig. 2. Proposed Model for W7 Key Stream Generator

The function unit is responsible for the keystream generation. The proposed architecture for the hardware implementation of one cell is presented in Fig. 7. Each cell has two inputs and one output. The one input is the key and it is the same for all the cells. The other input consists of control signals.

Finally, the output is 1-bit long. The outputs of each cell form the keystream byte.

IV. COMBINATION OF RGB SUBSTITUTION TECHNIQUE

First, we get plain text and convert them into characters. After that we convert each character into RGB values as you can see in Fig.3:

Fig. 3. RGB Substitution Values for Each Character

After completing every character RGB value it will look like as shown in Fig.4:

Fig. 4. RGB Spectrum, Image created by RGB values

After getting this image we apply AES Encryption to get encrypted Images that cannot be readable by intruders as shown in Fig.5:

Fig. 5. Encrypted Image

V. MODEL ANALYSIS

[1]. In their work, there are mainly two stages. The first stage deals with the transformation here from Plain Text to image. The second level contains Image-Shuffle Encryption which is based on an Efficient digital encryption algorithm based on the matrix scrambling technique [2] where the Image generated by the transformation is stored in the matrix form at the bit level and this matrix has been shuffled by the technique described in [2]. The two operations involved here are performed on the client-side and to obtain the original text same operations are performed in the reverse direction on the receiver side. In the first level i.e. Text-To-Image Encryption, each letter of a text file is transformed into three random integers say RGB R for Red, G for Green, and B for Blue. The range of Random numbers is from 0 to 255. Each of the three random numbers represents a single pixel in the image. In their algorithm, they have generated an individual pixel (R, G, and B values calling them RGB value) for each letter in the plain text. During this process, key1 is generated by Key Stream Generator which contains the random numbers RGB for all the letters. This key1 is stored in one string and used to transform the plaintext into an image. At the bit level, the result of this process is stored in a two-dimensional array or Matrix of Pixels MP. In this Matrix, every 3 contiguous columns in a row represent one letter. To make it more secure they used the second level of encryption, here they determine the number of times the image matrix is shuffled [2]; say N. Here N is equal to the number of columns of MP. On shuffling the matrix MP every time two random numbers are generated say R1, and R2, where R1 represents row/column number and R2 represents another row/column number. R1 is replaced by R2 and R2 is replaced by R1. The Shuffled matrix generated says SP, is finally sent to the Receiver. When the Receiver receives SP it uses key 2 to retrieve the original matrix MP and then each pixel in the original matrix MP is decomposed into R, G, and B values. Then using key 1 these 3 contiguous values (R, G, and B) are transformed to a specific letter.

Fig. 6. Proposed Model

After that transformation, AES Apply on the Image and convert that image into an encrypted image that is unreadable and unguessable where it is actually image or text.

VI. CONCLUSION

A Modified AES Based Algorithm for Text To Image Encryption Using a Combination of RGB Substitution Techniques is used to encrypt credentials and save them into the database. This Algorithm should be implemented at highly sensitive security portals.

REFERENCES

[1] Ahmad Abusukhon Mohammad Talib, A Novel Network Security Algorithm Based on Private Key Encryption, IEEE International Conference on Cyber Security, Cyber Warfare and Digital Forensic (CyberSec), 2012.

[2] Kiran Kumar, M., Mukthyar Azam, S., and Rasool, S.(2010), Efficient digital encryption algorithm based on matrix scrambling technique, International Journal of Network Security and its Applications (IJNSA), 2(4).

[3] Sourabh Singh and Anurag Jain, Combination of RGB Substitution for Text to Image Encryption Technique using AES, Spvryans International Journal of Engineering Sciences and Technology (SEST) ) ISSN: 2394- 0905

[4] M. Zeghid, M. Machhout, L. Khriji, A. Baganne, and R. Tourki, A Modified AES Based Algorithm for Image Encryption, World Academy of Science, Engineering and Technology International Journal of Computer, Electrical, Automation, Control, and Information Engineering Vol:1, No:3, 2007

--

--

Muzammil Ahmed

Senior Software Engineer | Full-Stack Developer | Applied Data Science Specialist | Azure DevOps | Agile/Scrum