Image Encryption in QR Codes

By Aniya Pandey

What is Encryption and why it is needed?

For a long time, secure data transmission has been a big problem for organizations and governments. It can be some secrets involving trades or some government mission critical data. Ciphers has been used since historical times for different purposes. Shift ciphers which were not so difficult did took time to break then.

1

Caesar Cipher used in times of Julius Caesar

Later in the age of computing, ciphers were started being used with software. And which gave rise to new challenges like protecting these against brute force attacks and other vulnerabilities. Key lengths were varied and Data Encryption Standards (DES) was set up . All the ciphers which are present today can encrypt all kinds of data available.

Image Encryption (Method followed):

 

Two matrices c0 and c1, that would be of dimensions [n x m] where n is total number of shares. Now this is based on the Moni Naor and Adi Shamir’s visual cryptography scheme. According to their theory first the image is divided into shares to follow encryption and to get that image back, we need to recombine the shares. And since we are talking at digital level, we will talk about pixels. Encryption is done in following manner in pixels of an image:

So, we have a source image:

2

And while going through the encryption process it goes as follows:

3
So, if we recombine the shares, we will get an image that would be blurred and 4 times larger than the actual image which is one of the problems if we follow this method.

3a

This loss in contrast happens because of the translation of pixels during encryption process because of which black pixels remain same but white pixels turn gray.

Algorithm followed (Flowchart):

Python script was written and the algorithm according to this flowchart was followed.

4

Problems with using the above method:

It was clearly visible, in the examples above that the output that came out was blurred and 4 times the actual image which is not we want. We always want that we should at least get 99% of the original image back.
Though in case of the example shown above, the image we got is almost 90% clear and things are quite clearly visible. But if take an image where we have TEXT in pictorial form and that is some kind of message that we want to encrypt. This is what will happen to that image as shown below:

5

We can see that clearly, that the Visibility has gone down, and it is not easy to read the message.

And another drawback of storing texts in images is that, there is always limit to the size of information that we can store in our images. Like we cannot increase the size of image, as the image has a fixed size. Like if there are thousands of lines that we have thousands of lines that we want share in secure way in pictorial form, but image is not capable of storing that. So there is better method in which using large information is possible and that is use of Q-R Codes.

 Q-R Codes:

QR-Codes (Quick Response Codes) are the combination of black squares arranged in white background. QR- Code came out as the result of trademark of Bar-code. QR-Codes can be read and scanned by any imaging devices like scanner and camera or mobile-phone camera or the QR-code laser scanner. Required information is extracted from the pattern and which are there in horizontal and vertical constituents of the images.

Codewords are 8 bits long and use the Reed-Solomon error correction algorithm with four error correction levels. The higher the error correction level, the less storage capacity. The following table lists the approximate error correction capability at each of the four levels:

  1. Level L (Low) 7
  2. Level M (Medium) 15
  3. Level Q (Quartile) 25
  4. Level H (High) 30

Example of Q-R Code:

6

Now for solving the problem we were having with image encryption that was of contrast loss, we can store our data in Q-R Codes and if we encrypt our Q-R Codes and after recombining the shares what we get back, would be blur image, but that image can be scanned and we can get the information. And I considered low error corrections in this code of all the other options.

So the in the example below we have a Q-R Code which contains a google link:

7

After going through encryption process and decryption we would again get a 4 times larger image and bit blurred. But the difference here is that even after the image is blurred, the code can be scanned and we can get the desired output.

This is the Q-R Code we get after complete encryption decryption process which is 4 times larger and blurred.

8

And after scanning the image using a mobile phone camera, we can see below that we get the desired result. So there is no loss of data in this case as the even the blurr Q-R Codes can be scanned and so our purpose of encrypting the image and getting the exact information we desire is achieved.                  

                9

Scanning Q-R Code

10

Google link found.

Now if we have large amount of data, like many lines of texts and we want to store that in pictorial form, we can store that in Q-R Codes easily and encrypt the Q-R Code. And after decryption we can scan that Q-R Code which would blurred but can be scanned like the case above. Example shown below :

11
This Q-R Code consists of multiple lines of code.

After encryption and decryption process we will get the following result:

12

Now this Q-R was scanner and result came out as follows:

13

Code Scanned

14

Multiple Lines texts as result

Conclusions:

So after going through the entire process, following conclusions were drwan:

  1. Image encryption is based on Moni Naor and Adi Shamir’s research.
  2. For normal images after following whole encryptio and decryption process the image gets 4 times larger and blurred.
  3. Image gets blurred because of translation of pixels.
  4. So Q-R Codes are better to use.
  5. Q-R Codes can store large amount of data.
  6. And even if the Q-R Codes gets blurred and size increases, it can be scanned to reterive the secure information

References:

  1. https://link.springer.com/article/10.1007/s13319-014-0029-0
  2. https://www.nature.com/articles/srep10374
  3. http://www.fe.infn.it/u/filimanto/scienza/webkrypto/visualdecryption.pdf
  4. https://books.google.com/books?id=gytHgadVA5sC&pg=PA1&lpg=PA1&dq=moni+naor+and+adi+shamir+research&source=bl&ots=Nt4xQsxyhm&sig=V2sTKdfCzyHmt_3UbUmpuD7W8mc&hl=en&sa=X&ved=0ahUKEwjg4bD3wN7TAhVD8CYKHY9yAK0Q6AEIXzAJ#v=onepage&q=moni%20naor%20and%20adi%20shamir%20research&f=false
  5. http://www.sciencedirect.com/science/article/pii/S0031320302002583
  6. http://dl.acm.org/citation.cfm?id=2743130
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s