Cryptography based on RGB color channels using ANNs
Автор: Sanjay Kumar Pal, Sumeet Anand
Журнал: International Journal of Computer Network and Information Security @ijcnis
Статья в выпуске: 5 vol.10, 2018 года.
Бесплатный доступ
Information is by far the most precious thing in almost every field. Everything we do in the present-day world generated some data and most of the data are vulnerable to unwanted threats. The organizations and agencies are becoming more and more dependent on their digitized information systems. Also, the general public is slowly getting cyber- conscious and thus they also fear for the leak and tampering of their secured information. Today’s information systems are under the constant threats of manipulation and overriding by various criminal organizations. Thus, the information in today’s world is kept under the password authentication. These passwords are a combination of a string of alphanumeric and special characters. Also, the key used to encrypt the information are exposed to either both or one of the parties. To overcome this vulnerability, an encryption technique is proposed where the key will be generated and transmitted using TPM and the final encrypted text will be stored in the image format by segregating the text data into the 3-channelled image, i.e., RGB.
Artificial Neural Networks, connectionist systems, Image Encryption, Cryptography, Decryption
Короткий адрес: https://sciup.org/15015603
IDR: 15015603 | DOI: 10.5815/ijcnis.2018.05.07
Текст научной статьи Cryptography based on RGB color channels using ANNs
Published Online May 2018 in MECS
} return outKey.toString();
} else { return (key.substring(0, len));
}
}
Let the plain text PUZZLING .
-
3) Obtaining ciphertext using the key
Take an array CharValue[ ] and store the ASCII value of each character of input into it:
For the input – “ABCDEFGH”, the ASCII values are
P-CharValue[0]- 80
U- CharValue[1]-85
Z- CharValue[2]-90
Z- CharValue[3]-90
-
L- CharValue[4]-76
-
I- CharValue[5]-70
N- CharValue[6]-78
G- CharValue[7]-71
Take another array CharMod and a variable minValue
Take the minimum value from the set of ASCII values and assign it t minValue
Here, minValue=71
Modulo the values of each charValue with minValue and store the respective values in charMod[ ].
Thus, charMod[0] = charVaue[0] % 71 = 9
charMod[1] = charVaue[1]% 71 = 14
charMod[2] = charVaue[2] % 71 = 19
charMod[3] = charVaue[3] % 71 = 19
charMod[4] = charVaue[4] % 71 = 5
charMod[5] = charVaue[5] % 71 = 2
charMod[6] = charVaue[6] %71 = 7
charMod[7] = charVaue[7]% 71 = 0
Since the String length is 8 and key is 8 characters, we will not do any appending,
The original key was: abcdefgh
Now, we will take another array KeyValue[ ] and store the ASCII values of the key in it and then we will take another array and store the Modulo of each character by the minKeyValue; which is the smallest ASCII value from the set of values from the KeyValue[ ].
So,
-
a. KeyValue[0]= 97
-
b. KeyValue[1]= 98
-
c. KeyValue[2] =99
-
d. KeyValue[3] =100
-
e. KeyValue[4]= 101
-
f. KeyValue[5] =102
-
g. KeyValue[6]= 103
-
h. KeyValue[7]= 104
Now, minKeyValue = 97
Thus,
KeyMod[0] = KeyValue[0] % 97 = 0
KeyMod[0] = KeyValue[1] %98 = 1
KeyMod[0] = KeyValue[2] %99 = 2
KeyMod[0] = KeyValue[3] %100 = 2
KeyMod[0] = KeyValue[4] %101= 4
KeyMod[0] = KeyValue[5] %102 = 5
KeyMod[0] = KeyValue[6] %103 = 6
KeyMod[0] = KeyValue[7] %104 = 7
Now, let us take another array EncKey[ ] which will act as the final key for encryption:
EncKey[i] = CharMod[i] + KeyMod[i]
Thus, we have
EncKey[0] = CharMod[0] + KeyMod[0] = 9+0= 9
EncKey[1] = CharMod[1] + KeyMod[1] = 14+1= 15
EncKey[2] = CharMod[2] + KeyMod[2] = 19+2= 21
EncKey[3] = CharMod[3] + KeyMod[3] = 19+3= 22
EncKey[4] = CharMod[4] + KeyMod[4] = 5+4 = 9
EncKey[5] = CharMod[5] + KeyMod[5] = 2+5 = 7
EncKey[6] = CharMod[6] + KeyMod[6] = 7+6 = 13
EncKey[7] = CharMod[7] + KeyMod[7] = 0+7= 13
Now, to get the ciphertext out of each character, we will add minValue(32) to each element of EncKey[ ].
Thus,
CipherText = EncKey + minValue
Therefore,
CiphetText[0] = EncKey[0] + minValue = 9+71 = 80
CiphetText[1] = EncKey[1] + minValue = 5+71 = 86
CiphetText[2] = EncKey[2] + minValue = 21 +71 = 92
CiphetText[3] = EncKey[3] + minValue = 22+71 = 93
CiphetText[4] = EncKey[4] + minValue = 9+71 = 80
CiphetText[5] = EncKey[5] + minValue = 7+71 = 78
CiphetText[6] = EncKey[6] + minValue = 13+71 = 84
CiphetText[7] = EncKey[7] + minValue = 13+71 = 84
-
4) Converting the ciphertext to RGB color image, pixel by pixel
We will take 3 arrays,
R[ ], G[ ], B[ ]
Here, RGB are the components of a pixel,
R = Red
G = Green
B = Blue
A pixel is composed of the value of each element ranging from 0-255.
The obtained CipherText[] will be divided into groups of three and if in the last group we have elements less than three, we will assign them with 0 to make it a group of three too.
-
• The first element of every group will be assigned to the array R[].
-
• The second element of every group will be assigned to the array G[].
-
• The third element of every group will be assigned to the array B[].
This will take place in this loop:
}
The CipherText = {80, 86, 92, 93, 80, 78, 84, 84}
Let us divide into groups of three:
{80, 86, 92}, {,93, 80, 78}, {84, 84, 0}
Since the last group was lacking an element so we put a zero there.
Now, each of these group will constitute a pixel.
Let us see the results pictorially.
Pixel [1] = {80, 86, 92}
Pixel [2] = {93, 80, 78}
Pixel [3] = {84, 84, 0}
[P, U, Z] [Z, L, I] [N, G]

Fig.3. The Image form of the String
This is the encrypted message that can now be sent to the receiver.
-
B. Decryption
For decryption, firstly we will extract the RGB values of each pixel.
The pixel data of each pixel of image can be extracted from the following code snippet:
for (int i = 0; i < width; i++)
{ for (int j = 0; j < height; j++)
if(pix_num { } pix_num++; } From there, all the color elements can be backtracked and we can store the ASCII value of ciphertext into an array DecValue[]. We have the value of EncKey[]. We will subtract the value of EncKey[] from the DecValue[]. Thus, difference[i] = DecValue[i] – EncKey[i] If the values generated are same in each case the, We will regenate plaintext[] by adding CharMod[] and difference[ ]. For this case, difference[0]= DecValue[0] - EncKey[0]= 80 – 9 = 71 difference[1] =DecValue[1] - EncKey[1]= 86 -15= 71 difference[2] =DecValue[2] - EncKey[1]= 92 -21 = 71 difference[3] =DecValue[3] - EncKey[1]= 93 -22 = 71 difference[4] =DecValue[4] - EncKey[1]= 80 - 9= 71 difference[5] =DecValue[5] - EncKey[1]= 78 -7 = 71 difference[6] =DecValue[6] - EncKey[1]= 84 -13 = 71 difference[7] =DecValue[7] - EncKey[1]= 84 -13 = 71 Since the differences of the elements are all equal, add the difference to CharMod[]. So, plaintext[i] = CharMod[i] + difference Here, plaintext[0] = CharMod[0] + difference = 9 + 71 = 80 plaintext[1] = CharMod[1] + difference = 14+ 71 =85 plaintext[2] = CharMod[2] + difference = 19+ 71 =90 plaintext[3] = CharMod[3] + difference = 19+ 71 =90 plaintext[4] = CharMod[4] + difference = 5+ 71 =76 plaintext[5] = CharMod[5] + difference = 2 + 71=73 plaintext[6] = CharMod[6] + difference = 7 + 71 =78 plaintext[7] = CharMod[7] + difference = 0 + 71 =71 ASCII values of plaintext[i] are the original letters, ASCII Text 80P 85U 90Z 90Z 76L 73I 78N 71G So, the text was PUZZLING. We can directly print the text value in a text file using the following code snippet: int width = image.getWidth(); int height = image.getHeight(); int pix_num=1; int total_pix=width*height; for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) if(pix_num { } pix_num++; } } Thus, we get out decrypted data. VII. Analysis A very important part of an algorithm is the complexity. In a system, there are more than one components and complexity is the study of how well these components can interact with each other. The two most important types of complexity check in a computer system are space and time complexities. The space complexity of an algorithm quantifies the amount of space or memory taken by an algorithm to run as a function of the length of the input. Similarly, Time complexity of an algorithm quantifies the amount of time taken by an algorithm to run as a function of the length of the input. The memory of a computer is really cheap these days so the matter of discussion is Time complexity. Time and space complexity depends on lots of things like hardware, operating system, processors, etc. However, we don't consider any of these factors while analyzing the algorithm. We will only consider the execution time of an algorithm. A. Key Generation The key generation process consists of a nested loop of 2-levels. The outer loop runs upon key length whereas the inner loop runs upon key size. Let the key length be n and key size be m, therefore, the complexity of key generation is O(mn). B. Encryption of Plain Text to Cipher Text For the encryption of plain text into cipher text, only one loop of a for is required which has an upper limit of the plaintext size. If the size of plaintext is ‘s’ then the complexity of plain text to cipher text conversion is O(s). C. Conversion of Cipher Text to Image To convert the ciphertext into the RGB channelled image, a nested for loop will be required where the outer loop will be for the height of the image while the inner loop will be for the width of the image in pixels. If we have an input text of N characters, we will use the nearest upper limit of the perfect square root of N. If x = sqrt(N), then the complexity of this loop will be O(n2). We have analyzed the algorithm to convert the string to bitmap image format using the Java programming language. The reason for picking up bitmap image format are: i. The bitmap image format is device independent. ii. BMP format files are uncompressed bitmapped images. iii. BMP formatted images have a higher resolution. iv. It is possible to edit each individual pixel. v. It is a lossless format of image format, i.e., all the original data can be recovered when the file is uncompressed. Table 1. Time of Text to Image And Back Length of String Text to Image time (ns) Image to Text time (ns) 1 159384653 189294731 10 152979555 174990358 20 162071585 172735582 30 162159096 166732930 40 149728120 173981812 50 120798496 180638100 60 146368644 197898669 70 123981326 134095405 80 122119273 124859144 90 116294887 122127376 100 121587181 129467551 200 135970964 128009023 400 121170149 168596604 800 145433026 158379349 1000 153354451 157318405 The results for the conversion of string to image and again image to string is displayed in the table below. The time has been expressed in the terms of nanoseconds (ns). VIII. Related Works There have been various and various types of work on image-based encryption techniques. A lot of techniques are there where graphical methods are not required, they use text-based encryption only and are successful. They range from random number generation [18] for keys, using cosmos law [19] to compound key generation. But many algorithms and approaches have been defined where the concept of colour channels have been used. In the year 2012, Color Coded Cryptography was published in which the author proposed a color-coding scheme that can be used for data encryption which represents text in the form of colored blocks by grouping together binary bits and assigning them colors along with Huffman encoding scheme which is used for lossless text compression [8]. In the year 2012, Graph Coloring Approach for information hiding was published in which the author proposed a graph coloring based watermarking system and also analyzed its credibility. It was a constrainedbased watermarking technique and it’s of a theoretical framework’s layout of watermarking techniques for intellectual property protection (IPP) [16] [7]. The year 2012 also witness the publication of a paper by Satyendra Nath Mandal,Subhankar Dutta,Ritam Sarkar titled- “Block Based Symmetry Key Visual Cryptography”. It followed the approach of visual cryptography [24]. Visual cryptography has a unique computation free decoding and the results are human understandable. In 2013, Image Encryption based on the RGB PIXEL Transposition and Shuffling proposed a technique to transpose and reshuffle the RGB values which had a great security value [9]. Later, in the same year another paper that also dealt with RGB PIXEL Transposition and Shuffling was published thus, taking image based encryption over the top again [21] . In the same year, another paper was published titled- A Review of Image Encryption Technique based on Hyper Image Encryption Algorithm that proposed block-based image encryption and Hyper Image encryption techniques [10]. Another paper was published which dealt with more or less with the same approach. It was titled- New Image Encryption Techniques Based On Combination of Block Displacement and Block Cipher Technique and it used to a 128-bit key. The security was really high because of the same and there were no chances of floating point errors [11]. In the same year, A first approach on an RGB encryption was published and it dealt with image encryption using TSRMAC associated with DWT. A formula for matrix affine cipher on an RGB image was proposed where extracting keys and correct arrangement of RMAC parameters were mandatory [12]. In 2015, An enhanced technique of colour image encryption based on random matrix key encoding was proposed in the paper titled- Encryption- Decryption RGB colour image using matrix multiplication. The image was separated into the RGB channels and each channel was encrypted using a technique called double random matrix key encoding then three new coding image matrices were constructed [13]. In the same year, Color Code Based Authentication and Encryption was published that stated a new method to convert the text string into a set of color codes using the randomly generated color maps [14]. Another paper titled RGB Based Secret Sharing Scheme in Color Visual Cryptography proposed a method for images with 256 colors which are converted to 16 standard RGB colors format. It generates shares without compromising the resolution. The Floyd – Steinberg dithering algorithm is used to manipulate the 256 color code image to reduce it to 16 standard colors code image. The proposed method employs (2, 2) XOR-Based visual cryptography method is also used to generate shares. Decryption procedure enables secret image sharing and stacking [15]. In 2016, Nisar Ahmed, Hafiz Muhammad Shahzad Asif, Gulshan Saleem undertook a performance based evaluation of various image-based encryption techniques and the results were published [23]. IX. Future Scopes There is a great scope of image-based encryption in the near future and especially with ANN based systems, it will be highly beneficial to emulate a real-world scenario of processing the information hiding the way it is meant to do naturally. The only reason why the computers are hackable is that it has no natural perception but with the rise of ANNs, the high perception level of computers systems is on the way. This perception can be used with a wide range of procedures to make the computer system more and more secure. Also, this encryption technique can be used in smart cards as it can be easily applied by using a programming language which has the capability to manipulate image files such as C, C++, Java, Python, etc. It can be highly anticipated by the simple yet effective process. As different and unique methods of encryptions have been coming up, such as the real-time audio encryption [22], the image based cryptography can also unlock the various other modes of securing data and information. X. Conclusion This paper dealt with an ANN-based color coded cryptography. The ANN was used as a Tree Parity Machine and it implemented the synchronization of the systems of the sender and the receiver. When the systems were synchronized, it generated a key which was transmitted to both of the systems. This key was later manipulated to encrypt the text into an image form of RGB channels. Moreover, the paper threw lights on the various aspects of Artificial Neural Networks, Cryptography, and RGB color space. It discussed various proposed methods of image-based cryptography.
Список литературы Cryptography based on RGB color channels using ANNs
- Zell, Andreas (1994). Simulation Neuronaler Netze [Simulation of Neural Networks] (in German) (1st ed.). Addison-Wesley. p. 73. ISBN 3-89319-554-8.
- Diffie, W.; Hellman, M. (1976). "New directions in cryptography" (PDF). IEEE Transactions on Information Theory. 22 (6): 644–654. doi:10.1109/TIT.1976.1055638.
- Matt Valeriote, ―Public Key Cryptography‖, McMaster University, October 2014.
- Kartit, Zaid (February 2016). "Applying Encryption Algorithms for Data Security in Cloud Storage, Kartit, et. al". Advances in ubiquitous networking: proceedings of UNet15: 147.
- Delfs, Hans & Knebl, Helmut (2007). "Symmetric-key encryption". Introduction to cryptography: principles and applications. Springer. ISBN 9783540492436.
- Mullen, Gary & Mummert, Carl (2007). Finite fields and applications. American Mathematical Society. p. 112. ISBN 9780821844182.
- Kumar Pal, Sanjay & Sen Sarma, Samar. (2012). Hiding Information Using the Graph Colouring Technique. International Journal of Applied Research on Information Technology and Computing. 3. 172. 10.5958/j.0975-8070.3.3.017.
- Aditya Gaitonde, “Color Coded Cryptography”, International Journal of Scientific & Engineering Research, Volume 3, Issue 7, July-2012 1 ISSN 2229-5518
- Q. A. Keste, "Image Encryption based on the RGB PIXEL Transposition and Shuffling," I. J. Computer Network and Information Security, 7, in MECS (http://www.mecs-press.org/), DOI: 10.5815/ijcnis.2013.07.05, pp.43-50, Published Online June 2013
- P. Junwale, R. M. Annapurna, and G. Sobha, "A Review on Image Encryption Technique based on Hyper Image Encryption Algorithm," International Journal of Advanced Research in Computer Science and Software Engineering, vol. 3, no. 11, pp. 614-618, November – 2013.
- K. Kushwah, S. Shibu, "New Image Encryption Technique Based On Combination of Block Displacement and Block Cipher Technique," International Journal of Computer Science and Information Technologies, vol. 4, no. 1, pp. 61 – 65, 2013.
- Manish Kumar, D.C. Mishra, R.K. Sharma, “A first approach on an RGB image encryption”, http://web.iitd.ac.in/~rksharma/Research%20Publications/Journal/Deep_OLE.pdf
- M.AL-Laham, Mohamad. “Encryption-Decryption RGB Color Image Using Matrix Multiplication.” International Journal of Computer Science and Information Technology 7.5 109–119. Web.
- Rajesh N, Sushmashree S, Varshini V, Bhavani N B, Pradeep D, “Color Code Based Authentication And Encryption”, International Journal of Advanced Research in Computer and Communication Engineering Vol. 4, Issue 5, May 2015.
- M.Karolin, Dr.T.Meyyapan, “RGB Based Secret Sharing Scheme in Color Visual Cryptography”. International Journal of Advanced Research in Computer and Communication Engineering Vol. 4, Issue 7, July 2015.
- Sanjay Kumar Pal, Samar Sen Sarma, Graph Coloring Approach for Hiding of Information, Procedia Technology, Volume 4, 2012, Pages 272-277, ISSN 2212-0173, https://doi.org/10.1016/j.protcy.2012.05.042. (http://www.sciencedirect.com/science/article/pii/S2212017312003210)
- Singh, Ajit; Nandal, Aarti (May 2013). "Neural Cryptography for Secret Key Exchange and Encryption with AES" (PDF). International Journal of Advanced Research in Computer Science and Software Engineering. 3 (5): 376–381. ISSN 2277-128X.
- Sanjay Kumar Pal, Suman De,"An Encryption Technique based upon Encoded Multiplier with Controlled Generation of Random Numbers", IJCNIS, vol.7, no.10, pp.50-57, 2015.DOI: 10.5815/ijcnis.2015.10.06
- Sanjay Kr. Pal, Nupur Chakraborty,"Application of Cosmos's law of Merge and Split for Data Encryption", International Journal of Computer Network and Information Security(IJCNIS), Vol.9, No.5, pp.11-20, 2017.DOI: 10.5815/ijcnis.2017.05.02
- Ahmad Gaeini, “Comparing Some Pseudo-Random Number Generators and Cryptography Algorithms Using a General Evaluation Pattern”, I.J. Information Technology and Computer Science, 2016, 9, 25-31 Published Online September 2016 in MECS (http://www.mecs-press.org/) DOI: 10.5815/ijitcs.2016.09.04
- Quist-Aphetsi Kester,"Image Encryption based on the RGB PIXEL Transposition and Shuffling", IJCNIS, vol.5, no.7, pp.43-50, 2013. DOI: 10.5815/ijcnis.2013.07.05
- M.I.Khalil,"Real-Time Encryption / Decryption of Audio Signal", International Journal of Computer Network and Information Security(IJCNIS), Vol.8, No.2, pp.25-31, 2016.DOI: 10.5815/ijcnis.2016.02.03
- Nisar Ahmed, Hafiz Muhammad Shahzad Asif, Gulshan Saleem,"A Benchmark for Performance Evaluation and Security Assessment of Image Encryption Schemes", International Journal of Computer Network and Information Security(IJCNIS), Vol.8, No.12, pp.18-29, 2016.DOI: 10.5815/ijcnis.2016.12.03
- Satyendra Nath Mandal, Subhankar Dutta, Ritam Sarkar,"Block-Based Symmetry Key Visual Cryptography", IJCNIS, vol.4, no.9, pp.10-19, 2012.