2011 International Conference on Computer and Software Modeling IPCSIT vol.14 (2011) © (2011) IACSIT Press, Singapore Image Security via Genetic Algorithm Rasul Enayatifar a and Abdul Hanan Abdullah b a Department of Computer, Islamic Azad University, Firoozkooh Branch, Firoozkooh , Iran b Faculty of Computer Science & Information System, Universiti Teknologi Malaysia Abstract. In this paper, a new method based on a hybrid model composed of a genetic algorithm and a chaotic function is proposed for image encryption. In the proposed method, first a number of encrypted images are constructed using the original image with the help of the chaotic function. In the next stage, these encrypted images are employed as the initial population for starting the operation of the genetic algorithm. In each stages of the genetic algorithm, the answer obtained from previous iteration is optimized so that the best encrypted image with the highest entropy and the lowest correlation coefficient among adjacent pixels is produced. 1. Introduction With the ever-increasing growth of multimedia applications, security has become an important issue on communication and storage of images. Usually, encryption is one better way to ensure the high security. It is well-known that image encryption has extensively applications in Internet communication, multimedia systems, medical imaging, telemedicine, and so on [1]. One of the proposed methods was the tree structure method in which the quad tree structure is selected to be encrypted [2]. The advantage of such method was that it reduces the amount of time processing. The main problem to this method was it was only suitable for the quad tree compression algorithm which is not an international standard. Another introduced method for image encryption was Cellular automata (CA) [3, 4]. A recent proposed way is image encryption algorithm which can replace the pixel values in CBC-like mode by using recursive CA [4]. It can be seen that a theory is exists in many research areas. This theory which is called Chaos theory has many favorable usages for secure communication such as periodicity, sensitivity to initial conditions, control parameters and random-like behavior. These features can be linked to the properties of a suitable cipher. Due to the benefits of such a method, many scientists believe that this method can be a great help for image encryption [5, 6]. Many researchers have found a close knit relation between chaos and cryptography [7, 8].Recently, an encryption method has been proposed which is based on a compound sequence [9]. This scheme works in two ways; the first one deal with replacing the pixel values with XOR operations and the second one deal with circular change in position of permutations in rows and columns. In the proposed method, the chaotic function Logistic Map and a key extracted from the plain-image are used to encrypt the image. The method mentioned is employed to produce a number of encrypted images using the plain-image. These encrypted images are considered as the initial population for the genetic algorithm. Then, the genetic algorithm is used to optimize the encrypted images as much as possible. In the end, the best cipher-image is chosen as the final encryption image. In the rest of the paper, genetic algorithms and chaotic functions are introduced, the proposed method is explained, and then experimental results and the conclusions reached are presented. 198 2. Chaootic Functtion The chhaotic functiions are likee noise signals but they y are compleetely certain, that is if we w have thee primary quaantities and the drawn function, f the exact amou unt will be reproduced. T The advantaages of thesee signals will be as follow ws: [10] 1) The T sensitivityy to the prim mary conditioons: 2) Thhe apparentlyy accidental feature: 3) Thhe Determiniistic work The equuation (1) shhows one of the most fam mous signalss which has chaotic c featuures and is known k as thee logistic mapp signal. X n +1 = rX X n (1 − X n ) (1) In whicch the willl get the num mbers betweeen [0,1], thee signal show ws three diffferent chaoticc features inn three differeent range baased on the division d of thhe r parameter of which the signal feeature will be b as well byy consideringg the X0=0.3. 1) iff we have r € [0,3], then the t signal feaature in the first f 10 repetitions shhowed some chaos and affter that it waas fixed. n the first 200 repetition showed som me chaos andd 2) Iff we have r € [3, 3.57], then the signnal feature in afterr that it was fixed. f 3) Iff we have r € [3.57, 4], thhen the signaal feature is completely c chhaotic. Accordiing to the giiven descripttion and the research req quirements for f the compplete chaotic features forr image Encrryption, the logistic l map chaotic signnals with thee primary vallues of X0= 0.3and r € [3.57, 4], aree used. 3. The proposed p Method In ordder to form the t initial poopulation froom the plain--image, first the plain-im mage is divid ded into fourr equal parts, as shown inn Figure 1. Fig 1: a) Plain-image P b) Plain-imag ge divide to 4 equal parts Then, thhe chaotic fuunction logisttic map is em mployed to separately enccrypt all the pixels present in each off these four parts p as follow ws: 1- From m each part of the image, five pixels are a selected as a the encrypption key for forming the initial valuee of the Logiical Map fuunction and for f encryptinng that part. The selection of thesee pixels is based b on thee number of the t populatioon being form med. For exaample, if it is the first mem mber of the ppopulation being b formedd, then the firsst five pixelss of the first row are useed to form th he initial valuue. If it is thhe second meember of thee population being b formedd, then the fiirst five pixells of the seco ond row are used u to makee the key, etcc. 2- The initial valuee of the chaootic functionn logistic map p is determiined from thhe following equation byy g scales of the five pixxels. using the vaalues of the gray 199 , In whicch, , , , 2 represeents an eightt- bit block. Then, T equatio on 3 is used to t convert P into an ASC CII number. , , , , , ,…, , , , ,…, , , 3 , After P is turned intto an ASCII number, thee string B wiith a length of o 40 bits is produced. In n equation 3,, Pi, j stands for the b of the bit block. Finally, by usin ng equation 4, the initiaal value for starting thee execution of the chaoticc function loggistic map is obtained. , 2 , 2 , 2 , 2 , 2 2 1 1,2,3,4 4 In whicch, k is the number n of each part of thhe image (Fig gure 1.b). Byy using this rrelation, the initial valuee of the logisttic map function (U0k), which w lies in the t interval 0 to 1, is obtaained. 3- For each e part off the plain-im mage, step 2 is repeated.. Therefore, in the end, there will bee 4 differentt initial valuees for each im mage (one vaalue for each part of the image). 4- For encrypting e thhe pixels in each part off the image, the initial value v of that part and eq quation 5 aree used as folloows: 255 5 In equaation 5, the symbol reepresents XO OR, stands for the current value of th he pixel, andd NewValue shows s the neew value of the pixel aftter it is encry ypted. The value v of refers to the value off the chaotic function inn the parrt of the oriiginal imagee, which is determined for each steep by usingg equation 1. All the pixels in eacch part, exceppt the 5 pixels used as thee key, are sequentially (rrow by row) encrypted inn this way. Fiinally, the firrst member of o the populaation is built by b using the mentioned m method.(Figu ure 2) To build thee rest of the population, p s steps 1 through 5 are repeeated. Fig 2: First genneration of gen netic population 1.2 Genetiic Optimizattion 200 After forming the initial population, the genetic algorithm is used to optimize the encrypted images. The genetic algorithm introduced in this study uses the crossover operation as shown in Figure 3. Figures 3.a and 3.b show the input images for the crossover operation, and Figures 3.c and 3.d show these images after the crossover operation. Fig 3: a, b) Input images c, d) Images after crossover The fitness function used in this paper is the correlation coefficient between pairs of adjacent pixels of the image. At each stage, the new generations produced and the previous ones are evaluated using the fitness function and 50% of the population with the minimum correlation coefficient and 10% of the remaining population is selected for the next generations. In each generation, the individuals which are not selected as elites are not participating in reproduction in the entire algorithm, in spite of the fact that their combination with the elites may result in better solutions, therefore, 10% of the remaining population are chosen arbitrarily to help the selected 50% elites for production of the new generations. This process is repeated until the correlation coefficient of the best generation produced does not significantly change in two successive stages. After this stage, the generation which had the lowest correlation coefficient is encrypted as the final cipher-image. The only important point here is that in each generation the number of populations that generation is built must be maintained. In the end, the image having the lowest correlation coefficient and the number of the population, or the numbers of the two populations, the image is made from are sent to the destination. 4. Experimental Results In this section, the efficiency of the proposed method in the different parts is introduced. 4.1 Image Entropy Entropy is one of the prominent features in randomization. Information entropy is a mathematical theory for data communication and storage introduced in 1949 by Claude E Shannon. Equation 6 is introduced for obtaining entropy [11]. log 1 6 In which, N is the number of gray levels used in the image (for gray level images, N is 8), and ( ) shows the probability of having a gray level in the image. In images that are produced in a completely random way, N will be 8; which is considered as an ideal value. Our paper is shown entropy about 7.9978. 201 4.2 Correlation coefficient A good encryption algorithm is one in which the correlation coefficient between pairs of encrypted adjacent pixels in the horizontal, vertical, and diagonal positions are at the least possible level. The correlation coefficient is calculated by using equation 7. |cov x, y | 7 D y D x In the above relation, x and y are the gray levels in two adjacent pixels of the image. In calculating the correlation coefficients, the following equations are employed: cov x, y E x D x N 1 N 1 N 1 N x E x y E y , 8 N x, 9 N x E x . 10 To test the correlation coefficient between two adjacent vertical pixels, two adjacent horizontal pixels, and two adjacent diagonal pixels in a cipher-image, the following procedure is used: first, 2500 pairs of pixels are randomly selected, and then the correlation coefficient is obtained by using equation7(the results of which are shown in Table 1). Table1. Correlation coefficient of two adjacent pixels in two images Plain-Image Cipher-Image Vertical 0.9711 0.0093 Horizontal 0.9445 -0.0054 Diagonal 0.9217 -0.0009 4.3 Key analysis A suitable encryption algorithm must be sensitive to small changes in keys. Moreover, the key must be long enough to resist against brute-force attacks. In this study, a 40-bit long key is suggested which produces a key space equivalent to 2 (and hence this key seems to be long enough).To test the sensitivity of the key in the proposed method, first the Photographer image (Figure 4a) is encrypted using the proposed method (Figure 4b). Then, this same image is encrypted once again using the proposed method, with the difference that this time, in the stage of producing the initial population (when each member of the population is being produced), one bit of the key of the member is changed; and the population is formed in this way. After this new population is formed, the rest of the proposed method is executed, and in the end Figure 4c is obtained. Figure 4d shows the similarity of the two encrypted images (the white points are the common points of the two encrypted images). The two encrypted images are about 99.76% different. 5. Conclusions In this paper, a new method has been suggested for encrypting images by using the chaotic function logistic map and genetic algorithms. In this method, the chaotic function is employed for initial encryption and the genetic algorithm is used to improve the encryption process of the image. The main innovation in this paper is that this is the first time genetic algorithms are used in this way to encrypt images. Results obtained for correlation coefficients and the entropies of the images also prove the high efficiency of this 202 method, compared with other methods in image encryption. Moreover, this method, compared to other methods mentioned in this paper, has a higher stability in the face of attacks common in this area. Fig 4. (a) Plain-image, b,c) encrypted images using user keys with 1-bit difference in each parts; (d) the Similarity between (b) and (c) 6. References [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] X. F. Liao, S. Y.Lai and Q. Zhou. Signal Processing. 90 (2010) 2714–2722. H. Cheng and X. Li. IEEE Transactions on Signal Processive. 48 (8) (2000) 2439–2451. O. Lafe. Engineering Applications of Artificial Intelligence. 10 (6) (1998) 581–591. R. J. Chen and J. L. Lai. Pattern Recognition. 40 (2007) 1621–1631 R. Enayatifar. Journal of the Physics Science. (2011) 221-228. V. Patidar, N. K. Pareek, G. Purohit and K. K. Sud. Optics Communications, In Press, Corrected Proof, Available online 26 May 2011. S. Li, G. Chen and X. Zheng. Multimedia security handbook. LLC, Boca Raton, FL, USA: CRC Press; (2004) [chapter 4]. Y. Mao and G. Chen. Handbook of computational geometry for pattern recognition, computer vision, neural computing and robotics. Springer; (2003). X. Tong and M. Cui. Image and Vision Computing. 26(6) (2008) 843–850. H. S. Kwok, W. K. S. Tang, Chaos Solitons and Fractals, (2007) 1518–1529. H. S. Kwok and W. K.S. Tang, Chaos Solitons and Fractals, (2007) 1518–1529. 203