ARMY DATA ENCODE USING VISUAL

A Project report submitted in partial fulfillment of the requirements for

the award of the degree of

BACHELOR OF TECHNOLOGY

IN

COMPUTER SCIENCE ENGINEERING

Submitted by

M.V.R. NIKHIL 316126510029

B. NIKHIL 316126510006

K. SAI SANKAR 316126510023

SHIV SHANKAR SINGH 316126510050

D. SAI GANESH PATNAIK 316126510071

Under esteemed guidance of

Mr. G. Jagadish Assistant Professor Dept. of CSE

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING ANIL NEERUKONDA INSTITUTE OF TECHNOLOGY & SCIENCES (AUTONOMOUS) (Permanently Affiliated to Andhra University) SANGIVALASA: VISAKHAPATNAM – 531162 2019-2020

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING ANIL NEERUKONDA INSTITUTE OF TECHNOLOGY AND SCIENCES (UGC AUTONOMOUS) (Affiliated to AU, Approved by AICTE and Accredited by NBA & NAAC with ‘A’ Grade) Sangivalasa, Bheemili Mandal, Visakhapatnam dist.(A.P)

CERTIFICATE

This is to certify that the project report entitled “ARMY DATA ENCODE USING VISUAL CRYPTOGRAPHY” submitted by M.V.R. Nikhil(316126510029), B. Nikhil (316126510006), K. Sai Sankar(316126510023), Shiv Shankar Singh(316126510050), D. Sai Ganesh Patnaik(316126510071) in partial fulfilment of the requirements for the award of the degree of Bachelor of Technology in Computer Science Engineering of Anil Neerukonda Institute of technology and sciences (A), Visakhapatnam is a record of bonafide work carried out under my guidance and supervision.

Project Guide Head of the Department

Mr. G. Jagadish, Dr. R. Sivaranjani, Assistant Professor Professor Department of CSE Department of CSE ANITS ANITS

DECLARATION

We, M.V.R. NIKHIL, B. NIKHIL, K. SAI SANKAR, SHIV SHANKAR SINGH, D. SAI GANESH PATNAIK of final semester B.Tech., in the department of Computer Science and Engineering from ANITS, Visakhapatnam, hereby declare that the project work entitled ARMY DATA ENCODE USING VISUAL CRYPTOGRAPHY is carried out by us and submitted in partial fulfillment of the requirements for the award of Bachelor of Technology in Computer Science Engineering , under Anil Neerukonda Institute of Technology & Sciences(A) during the academic year 2016-2020 and has not been submitted to any other university for the award of any kind of degree.

M.V.R.NIKHIL 316126510029 B.NIKHIL 316126510006 K.SAI SANKAR 316126510023 SHIV SHANKAR SINGH 316126510050 D.SAI GANESH PATNAIK 316126510071

ACKNOWLEDGEMENT

We would like to express our deep gratitude to our project guide Mr. G. Jagadish, Assistant Professor, Department of Computer Science and Engineering, ANITS, for his guidance with unsurpassed knowledge and immense encouragement. We are grateful to Dr. R. Sivaranjani, Head of the Department, Computer Science and Engineering, for providing us with the required facilities for the completion of the project work.

We are very much thankful to the Principal and Management, ANITS, Sangivalasa, for their encouragement and cooperation to carry out this work.

We express our thanks to all the teaching faculty of Department of CSE, whose suggestions during reviews helped us in accomplishment of our project. We would like to thank all non-teaching staff of the Department of CSE, ANITS for providing great assistance in accomplishment of our project.

We also thank our project coordinator Dr. K. Suresh, Assistant Professor, Department of Computer Science and Engineering, ANITS, for his constant support throughout our project period.

We would like to thank our parents, friends, and classmates for their encouragement throughout our project period. At last but not the least, we thank everyone for supporting us directly or indirectly in completing this project successfully.

PROJECT STUDENTS

M.V.R. NIKHIL (316126510029) B. NIKHIL (316126510006) K.SAI SANKAR (316126510023)

SHIV SHANKAR SINGH (316126510050) D.SAI GANESH PATNAIK (316126510071)

ABSTRACT

In any army a decision is not directly taken by just one commander or leader but rather that same decision is taken only after discussing about that issue and a majority agrees upon it. This had become the base idea of our project.

In this project, the idea was to secretly transmit a secret image which can possible be any kind of important map or as such to the main people in the army and the original image can be formed only when the required number of people agree to that plan. This is done by the concept called “Visual Cryptography”. Visual Cryptography deals with images.

Visual cryptography is a technique which allows visual information such as images, videos etc. to be encrypted in such a way that the decrypted information appears as a visual image .In this project we implement visual cryptography on black and white images and color images(RGB) using “(k , n) secret image sharing algorithm” .This scheme is perfectly secure and very easy to implement. We extend this algorithm in such a way that the secret image is divided into n shares and each share is sent to n different officers and only when at least k officers (k ≤ n) agree to see the secret and when they combine their individual share, the secret is revealed.

Keywords cryptography, decryption, , k out of n shares, (k, n) algorithm, OR, RSA, shares, visual cryptography.

i

TABLE OF CONTENTS

ABSTRACT i

List of Figures v

List of Tables vii

1. INTRODUCTION 1

1.1 Digital Image Processing 1

1.1.1 Steps in Image Processing 1

1.1.2 What is an Image? 1

1.1.3 Representation of an image in a Matrix 2

1.1.4 Types of Images 2

1.2 Visual Cryptography 3

1.2.1 Cryptography 3

1.2.2 Visual Cryptography 3

1.3 Motivation for the work 4

1.4 Problem Statement 6

2. LITERATURE SURVEY 7

2.1 Binary Image 8

2.2 Quantization and Thresholding 10

2.3 Halftoning 11

2.4 Dithering 13

2.5 Human Visual System 15

ii

2.6 Shamir’s Secret Sharing Scheme 16

2.7 Secret Sharing Scheme Using Lagrange’s Interpolation Theorem 16

2.8 Two-out-of-two Secret Sharing Scheme 17

2.9 K-N Secret Sharing Scheme 19

2.10 Existing System 20

3.METHODOLOGY 22

3.1 Proposed System 23

3.1.1 System Architecture 23

3.1.2 Modules 25

3.1.2.1 Encryption 25

3.1.2.2 Division Into ‘n’ Shares 28

3.1.2.3 Generate and Send e-mails to each Shareholder 31

3.1.2.4 Overlapping ‘k’ Shares 31

3.1.2.5 Decryption 34

4.EXPERIMENTAL ANALYSIS AND RESULTS 37 4.1. System Configurations 37 4.1.1 Software Configurations 37 4.1.2 Hardware Configurations 37 4.2 Sample Code 38 4.3 Screenshots and Outputs 49 4.4 Experimental Analysis 59

iii

5.CONCLUSION AND FUTURE WORKS 62

5.1 Conclusion 62

5.2 Future Works 62

REFERENCES 64

APPENDIX 65

iv

LIST OF FIGURES

FIGURE FIGURE DESCRIPTION PAGE NO. NO. Fig(2.a) Bitmap Representation 9 Fig(2.b) Quantization levels for 8-bit representation of an Image 10 Fig(2.c) Original Image and its Threshold Image 11 Fig(2.d) Original Halftone Image v/s how a Human Eye sees a Halftoned 12 Image Fig(2.e) Original Image and Halftoned Image 13 Fig(2.f) Original Image, Image with Uniform Quantization and Dithering 14 Fig(2.g) Human Visual System as OR function 15 Fig(2.h) Construction of a two-out-of-two VC scheme: a secret pixel can be 18 encoded into two subpixels in each of the two shares. Fig(2.i) An example of two-out-of-two VC scheme. 19 Fig(3.a) System Architecture 23 Fig(3.b) Encryption and Division into ‘n’ shares 28 Fig(3.c) Merging at least ‘k’ shares and Decryption 33 Fig(3.d) Order of Encryption and Decryption 34 Fig(4.a) Home Page 49 Fig(4.b) Encryption and Dividing into ‘n’ Shares Page 50 Fig(4.c) Page after encryption and dividing into ‘n’ shares: also shows 50 which share is sent to which e-mail address. Fig(4.d) Merging ‘k’ Shares and Decryption Page 51 Fig(4.e) Output Page (when there are at least required number of ‘k’ shares 51 and keys of both RSA and Caesar Cipher are correct). Fig(4.f) Output Page (when there are at least required number of ‘k’ shares 52 and RSA is wrong and key of Caesar Cipher is correct). Fig(4.g) Output Page (when there are at least required number of ‘k’ shares 52 and key RSA is correct and key of Caesar Cipher is wrong). Fig(4.h) Output Page (when there are less than required number of ‘k’ shares 53 and keys of both RSA and Caesar Cipher are correct or wrong). Fig(4.i) Data Set that is worked on 53 Fig(4.j) Original Input Image 54 Fig(4.k) Encrypted Image(key in CC: god 54 Key in RSA: p=89,q=97,e=5,d=5069,n=8633) Fig(4.l) ‘n’ Shares of the Input Image 55 (n=5, k=4) Fig(4.m) Image obtained after merging at least ‘k’ shares (here 4 shares are 56 taken) Fig(4.n) Image obtained after merging less than ‘k’ shares (here 3 shares are 56 taken) and before decrypting

v

Fig(4.o) Output Image obtained when both the keys are correct 57 Fig(4.p) Output Image obtained when only the decryption key used in 57 Caesar Cipher is Wrong Fig(4.q) Output Image obtained when only the decryption key used in RSA 58 is Wrong. Fig(4.r) Output Image obtained when less than ‘k’ shares are combined. 58 Fig(app1) Structure of Django 67

vi

LIST OF TABLES

TABLE TABLE DECRIPTION PAGE NO. NO. Table 4.a RSA Encryption and Decryption times for images with different 59 resolutions Table 4.b Caesar Cipher Encryption and Decryption times for images with 60 different resolutions. Table 4.c Time taken for Dividing an Image into ‘n’ shares and Combining 60 ‘k’ shares to form an Image for images with different resolutions (n=5, k=4).

vii

1. INTRODUCTION

1.1 DIGITAL IMAGE PROCESSING

Digital Image Processing means processing digital image by means of a digital computer. We can also say that it is a use of computer algorithms, in order to get enhanced image either to extract some useful information.

1.1.1 Image processing mainly include the following steps:

1. Importing the image via image acquisition tools; 2. Analysing and manipulating the image; 3. Output in which result can be altered image or a report which is based on analysing that image.

1.1.2 What is an Image?

An image is defined as a two-dimensional function, F(x, y), where x and y are spatial coordinates, and the amplitude of ‘F’ at any pair of coordinates (x, y) is called the intensity of that image at that point. When x, y, and amplitude values of ‘F’ are finite, we call it a digital image.

In other words, an image can be defined by a two-dimensional array specifically arranged in rows and columns.

Digital Image is composed of a finite number of elements, each of which elements have a particular value at a particular location. These elements are referred to as picture elements, image elements, and pixels. A Pixel is most widely used to denote the elements of a Digital Image.

1

1.1.3 Representation of an Image in a Matrix

As we know, images are represented in rows and columns we have the following syntax in which images are represented:

The right side of this equation is digital image by definition. Every element of this matrix is called image element, picture element, or pixel.

1.1.4 Types of Images

1. BINARY IMAGE– The binary image as its name suggests, contain only two pixel elements i.e. 0 & 1, where 0 refers to black and 1 refers to white. This image is also known as Monochrome.

2. BLACK AND WHITE IMAGE– The image which consist of only black and white colour is called BLACK AND WHITE IMAGE.

3. 8 bit COLOUR FORMAT– It is the most famous image format. It has 256 different shades of colours in it and commonly known as Grayscale Image. In this format, 0 stands for Black, and 255 stands for white, and 127 stands for grey.

2

4. 16 bit COLOUR FORMAT– It is a colour image format. It has 65,536 different colours in it. It is also known as High Colour Format. In this format the distribution of colour is not as same as Grayscale image. A 16 bit format is actually divided into three further formats which are Red, Green and Blue which is the famous RGB format.

1.2 VISUAL CRYPTOGRAPHY

1.2.1 Cryptography

The word cryptography is derived from two Greek words which mean “secret writing”. Cryptography is the process of scrambling the original text by rearranging and substituting the original text, arranging it in a seemingly unreadable format for others.

Cryptography is an effective way to protect the information that is transmitting through the network communication path.

1.2.2 Visual Cryptography

Visual cryptography is a cryptographic technique which allows visual information (pictures, text, etc.) to be encrypted in such a way that decryption can be done just by sight reading. Visual cryptography, degree associated rising cryptography technology, uses the characteristics of human vision to rewrite encrypted photos. Visual cryptography provides secured digital transmission that is used just for merely the once.

Numerous guidance like military maps and business identifications are transmitted over the internet. Whereas pattern secret photos, security problems ought to be compelled to be taken into thought as a result of hackers may utilize weak link over the communication network to steal info that they need. To touch upon the protection problems with secret photos, varied image secret sharing

3

schemes are developed. anyone will use it for coding with none science information and any computations.

Visual Cryptography is one variant of Image Processing where we hide the secret image so that it is not visible as it has to be but is seen as a different image. Visual cryptography is the method of hiding images or documents by shadowing the original image into specific shares which are visually not recoverable. These shares when superimposed on one another would give away the concealed image which can be visually decrypted without further computation.

A secret is something which is kept from the knowledge of any but the initiated or privileged. Secret sharing denies a method by which a secret can be distributed between a group of participants, whereby each participant is allocated a piece of the secret. This piece of the secret is known as a share. The secret image can only be reconstructed when a sufficient number of shares are combined together. While these shares are separated, no information about the secret can be accessed. That is, the shares are completely useless while they are separated. These shares when superimposed on one another would give away the concealed image.

1.3 MOTIVATION FOR THE WORK

Numerous guidance like military maps and business identifications are transmitted over the internet. Whereas pattern secret photos, security problems ought to be compelled to be taken into thought as a result of hackers may utilize weak link over the communication network to steal info that they need. To touch upon the protection problems with secret photos, varied image secret sharing schemes are developed. anyone will use it for coding with none science information and any computations.

This very idea of sensitive data being tapped by the hackers motivated us to think of this project. Army maps are generally one of the most sensitive information to be retrieved by the hackers and if that happens, it might result in a disaster for that country.

4

This can happen when this stolen information goes into the wrong hands like terrorists. Now terrorists will have the information about the army plans that are being executed.

To prevent this from happening the map or any information related to the army is divided into a number of shares each of which bears some information but only when a minimum number of shares are put together. Individually, those shares are useless even if they are stolen and do not give away any important information. Only when a minimum number of shares are brought together the information is again reconstructed.

In any army, decisions are only taken when a number of people (higher officials) agree upon a particular idea. This is the main idea of this project. The information (image) is divided into ‘n’ number of shares and the original information can only be reconstructed or formed only when ‘k’ number of people agree on that idea (where k<=n) and combine them. Even if ‘k-1’ people agree to that idea and combine their shares, the original information cannot be retrieved back. This is the main motivation behind this project.

5

1.4 PROBLEM STATEMENT

Let ‘D’ be the secret image to be shared among ‘n’ parties. A (k, n)-threshold scheme is a way to divide,

‘D’ into ‘n’ pieces D1, . . . , Dn that satisfies the following conditions:

1. Knowledge of any ‘k’ or more Di pieces makes ‘D’ easily computable,

2. Knowledge of any ‘k -1’ or fewer Di pieces leaves ‘D’ completely undetermined (in the sense that all its possible values are equally likely).

We are using above algorithm for military purpose. We can use this process to share a confidential image data over a channel to different defense cadet.

Suppose we have to send a very highly confidential map image data to army officers deployed near battle field. We can split the image into ‘n’ shares and makes it compulsory for at least ‘k’ images to be merged to get the original image back. By doing so we can send ‘n’ shares of a secret image to ‘n’ army officers. They can only access this map image (secret image) only if at least ‘k’ officers agree on the orders given by the department.

Suppose out of ‘n’ officers ‘(k-1)’ are spies. Even if they have their share of image, they cannot recover the original image. There have to be at least ‘k’ images to get back the original image. By doing so we can provide a high level of security.

We also maintain a secret key value to provide extra security that will encrypt the original image. So, now to get the original image we not only we need ‘k’ image shares but also the key to decrypt it. Now it becomes very difficult to access the image by an unauthorized person.

6

2. LITERATURE SURVEY

Visual cryptography is a cryptographic technique which allows visual information to be encrypted in specific a way that decryption becomes a mechanical operation that does not require a computer. The idea was about producing image shares of a given secret image in a way that the image shares appear meaningless. Recovery of the image can be done by superimposing specified number of share images and, hence, the decoding process requires no special hardware or software and can be simply done by the human eye. Visual cryptography is a little more advantageous for implementation, while compared to conventional cryptography schemes, since the decryption process does not need any computation. Further, the image-based information becomes more secure, since only the intended recipient can reveal the true meaning of the decrypted image. Suppose the data (image) D is divided into n shares. D can be constructed from any k shares out of n shares. Complete knowledge of (k-1) shares reveals no information about D. So, k out of n shares is necessary to reveal secret data.

Visual cryptography technique was introduced by Naor and Shamir in 1994 as an alternative for conventional cryptography. They demonstrated a visual secret sharing plan, where a picture was separated into n imparts so that just somebody to all n shares could decode the picture, while any n-1 shares uncovered no data about the first original image. Each share was printed on a separate transparency, and decryption was performed by overlaying the shares. At the point when all n shares were overlaid, the first picture would show up. There are a few speculations of the fundamental plan including k-out-of-n visual cryptography. Rijimen displayed another 2-out-of-2 VC plot by applying the thought of shading mixture. When two transparencies superimposed on one another with distinctive colours, they lead to raises a third blended shading. In 2002, Nakajima predicted a new method of extended visual cryptography. This method is for regular images which are used to produce meaningful binary shares. This system works by taking three pictures as an input and generates two images which correspond to two of the three input pictures. The third picture is recreated by printing the two share pictures onto transparencies and stacking them together. By and large, visual

7 cryptography experiences the deterioration of the image quality. In this also describes the method to improve the quality of the output image. Binary visual cryptography scheme is proposed Hou et al. in the year 2004, which is applied to grey level images, that a grey level image is transformed into halftone images. The method that uses the density of the net dots to simulate the grey level is called Halftone and transforms an image with grey level into a binary image before processing. Halftone visual cryptography is proposed by the Zhi Zhou et al. In 2006 which produce meaningful and good high-quality halftone shares, the generated halftone shares contain the visual information. The basic idea of secret sharing was introduced by Shamir in the year 1994 in his paper “How to Share a Secret?” where a data D is divided into ‘n’ shares/pieces in such a way that ‘D’ can be easily reconstructed from any of the ‘k’ out of those ‘n’ shares/pieces, but the knowledge of at most ‘k-1’ pieces cannot reconstruct ‘D’. This was implemented by the concept of ‘Interpolation’. This idea was further developed into K-N Secret Sharing algorithm by using a Random Number where in each pixel value is being put in any of the ‘n-k+1 shares’(reconstruction factor) out of the ‘n’ shares so that a particular pixel value is definitely found in at least one of the ‘k’ shares that are being selected. We also made use of the paper “A Novel Approach on Secure Data Transfer for General Transactions using Secret Sharing Scheme”.

In addition to the above-mentioned algorithm, we introduced a cryptographic technique to encrypt the secret image and then divide it into ‘n’ shares. Later after combining ‘k’ shares we then need to decrypt the reconstructed image to get back the secret image. Here, in this project we used a simple symmetric cryptographic algorithm (Caesar Cipher) along with a strong asymmetric cryptographic algorithm (RSA) to provide more security.

2.1 BINARY IMAGE A binary image is a digital image that has only two possible values for each pixel. Typically, the two colours used for a binary image are black and white. The colour used for the object(s) in the image is the foreground colour while the rest of the image is the

8 background colour. In the document-scanning industry, this is often referred to as "bi- tonal". Binary images are also called bi-level or two-level. This means that each pixel is stored as a single bit—i.e., a 0 or 1. The names black-and-white, B&W, monochrome or monochromatic are often used for this concept, but may also designate any images that have only one sample per pixel, such as grayscale images. In Photoshop parlance, a binary image is the same as an image in "Bitmap" mode. Binary images often arise in digital image processing as masks or as the result of certain operations such as segmentation thresholding, and dithering Some input/output devices, such as laser printers fax machines and bilevel computer displays, can only handle bilevel images. A binary image can be stored in memory as a bitmap a packed array of bits. A 640×480 image requires 37.5 KiB of storage. Because of the small size of the image files, fax machine and document management solutions usually use this format. Most binary images also compress well with simple run-length compression schemes. Binary images can be interpreted as subsets of the two-dimensional integer lattice Z2; the field of morphological image processing was largely inspired by this view.

Fig 2.a Bitmap Representation

Allowing only one bit per pixel you can create two colours, black and white. These colours will be represented by the binary equivalent. So, for the colour white, the binary representation would be ’00’. And for Black the binary representation would be ’01’.

9

2.2 QUANTIZATION AND THRESHOLDING Quantization is the process of converting a continuous range of values into a finite range of discreet values. As number of bits to represent a pixel intensity (assume Gray scale image for convenience) is limited, quantization is needed. Suppose 8 bit is used for a pixel, it’s equivalent value ranges from 0 to 255 (discrete values). 0 is assigned to pure Black, and 255 is assigned to pure White. Intermediate values are assigned to grey scales as shown in this image. This process is quantization. For 8 bit pixels, quantization level is 256.

Fig 2.b Quantization levels for 8-bit representation of an Image

Image thresholding is a simple, yet effective, way of partitioning an image into a foreground and background. This image analysis technique is a type of image segmentation that isolates objects by converting grayscale images into binary images. Image thresholding is most effective in images with high levels of contrast.

10

Fig 2.c Original Image and its Threshold Image

To improve the threshold image and make it look much clearer, these techniques can be used 1. Halftoning 2. Dithering

2.3 HALFTONING Halftone is the reprographic technique that simulates continuous-tone imagery through the use of dots, varying either in size or in spacing, thus generating a gradient-like effect. "Halftone" can also be used to refer specifically to the image that is produced by this process. Where continuous-tone imagery contains an infinite range of colours or greys, the halftone process reduces visual reproductions to an image that is printed with only one colour of ink, in dots of differing size (pulse-width modulation) or spacing (frequency modulation) or both. This reproduction relies on a basic optical illusion when the halftone dots are small, the human eye interprets the patterned areas as if they were smooth tones. At a microscopic level, developed black-and-white photographic film also consists of only two colours, and not an infinite range of continuous tones. For details, see Film grain

11

Just as colour photography evolved with the addition of filters and film layers, colour printing is made possible by repeating the halftone process for each subtractive colour – most commonly using what is called the "CMYK colour model” The semi-opaque property of ink allows halftone dots of different colours to create another optical effect, full-colour imagery.

Fig 2.d Original Halftone Image v/s how a Human Eye sees a Halftoned Image

12

Fig 2.e Original Image and Halftoned Image 2.4 DITHERING Dithering is used in computer graphics to create the illusion of "color depth" in images with a limited color palette - a technique also known as color quantization. In a dithered image, colors that are not available in the palette are approximated by a diffusion of colored pixels from within the available palette. The human eye perceives the diffusion as a mixture of the colors within it. Dithered images, particularly those with relatively few colors, can often be distinguished by a characteristic graininess or speckled appearance.

By its nature, dithering introduces pattern into an image - the theory being that the image will be viewed from such a distance that the pattern is not discernible to the human eye. Unfortunately, this is not always the case, and often the patterning is visible - for example, with some images found on the web. In these circumstances it has been shown that a blue-noise dither pattern is the least unsightly and distracting. The error diffusion techniques were some of the first methods to generate blue-noise dithering patterns. However, other techniques such as ordered dithering can also generate blue-noise dithering without the tendency to degenerate into areas with artifacts.

13

Fig 2.f Original Image, Image with Uniform Quantization and Dithering

14

2.5 HUMAN VISUAL SYSTEM

Fig 2.g Human Visual System as OR function

Human visual system acts as an OR function. If two transparent objects are stacked together, the final stack of objects will be transparent. But if any of them is non- transparent, then the final stack of objects will be nontransparent. Like OR, 0 OR 0 = 0, considering 0 as transparent and 1 OR 0=1, 0 OR 1 =1, 1 OR 1=1, considering 1 as non- transparent.

15

2.6 SHAMIR’S SECRET SHARING SCHEME

Shamir’s Secret Sharing algorithm is an old cryptography algorithm (1979) invented by the Israeli cryptographer Adi Shamir (co-inventor of RSA) for sharing a secret across multiple parties

More particularly Shamir Secret Sharing Scheme (SSSS) enables to split a secret S in n parts such that with any k-out-of-n pieces you can reconstruct the original secret S, but with any k-1 pieces no information is exposed about S. That is conventionally called a (n, k) threshold scheme.

At first this may seem counterproductive in the context of secure data transmission because if there is a secure way of distributing a secret S amongst participants what is the point of using this scheme. The original purpose of the scheme is to enhance practicality and convenience when multiple parties are required to perform an authorized action.

2.7 SECRET SHARING SCHEME USING LAGRANGE’S INTERPOLATION THEOREM

Any method of dividing a secret into multiple (that is “n“) participants is secret sharing. Each person receives a piece of the secret and the secret can be recovered by combining some or all of the shares. The secret is in the form of polynomial of degree “t- 1”, where “t “is the number of keys needed to get the secret (i.e., threshold value). The polynomial is expressed mathematically as follows.

퐹(푥) = 푎푥

Where a is a coefficient. i

A (t,n) threshold secret sharing scheme is a used to distribute a secret “s” to “n” participants in such a way that a set of “t” or more participants can recover the secret “s” and a set of (t-1) or fewer participants cannot recover the secret “s”.

16

The secret to be shared consists in text data , but also images can be considered. The first scheme to share images was due to Naor and Shamir and it is called visual cryptography. It is based on visual threshold schemes t of n.

In this method, the coefficients a0, a1, …,at-1 are randomly generated .The polynomial with the coefficients a0, a1, …,at-1 of degree (t-1) is represented as follows.

F(x) = a0 + a1x + …..+ at-1xt-1

Let the registered participant be “n” and let t < n, where t is a threshold value. Each participant has their own identity value IDi ( i = 1 to n ) . The function value of the polynomial for the input of participant’s ID value is performed. Each function value is given to the corresponding participant. The function value for ID1 is share1; the function value for ID2 is share2 and so on. The sender sends share1 to the participant for ID1, share2 for ID2 and so on. The process is clear from the following flowchart. In the decryption process, each participant accepts a share from the sender for reconstructing the secret. This makes use of the Lagrange’s interpolation formula given below, 푥−푥 퐹(푥) = 푦(푖) 푥 −푥

Where x1 , x2, …… are the identification values. F(x) is the reconstructed polynomial, t is the Threshold value.

2.8 TWO-OUT-OF-TWO SECRET SHARING SCHEME

In two-out-of-two Secret Sharing Scheme, an image is divided into 2 shares and only by completely making use of these 2 shares we can get back the original image. A wrong pair of shares do not give us any information about the original image.

Rijimen presented a new 2-out-of-2 VC scheme by applying the idea of color mixture. The stacking two transparencies with different colors leads to raises a third mixed color.

17

Fig 2.h Construction of a two-out-of-two VC scheme: a secret pixel can be encoded into two subpixels in each of the two shares.

A common example of k out of k visual cryptography scheme is 2 out of 2 visual cryptography schemes. In (2, 2) Visual Cryptography Scheme, the original image is broken into 2 image shares. In original image, every pixel is represented by non- overlapping block of 2 or 4 sub-pixels in each share. If anyone is having only one share, will not be able to reveal any secret information. Both the shares are required to be superimposed to reveal the secret image.

There are many techniques for encoding the pixels of original image. In a technique, in which each pixel in original image is represented by two sub-pixels in each share, while reading the pixels in original image, if a white pixel is encountered, one of the first two rows in Figure given below is selected with probability 0.5, and the shares are assigned 2 pixel blocks as shown in the third and fourth columns in figure given below. Similarly, if a black pixel is encountered, one of the last two rows is selected with probability 0.5, from which a sub-pixel block is assigned to each share. When two shares are superimposed, if two white pixels overlap, the result will be white pixel and if a black pixel in one share overlaps with either a white or black pixel in another share, the result will be black pixel. This implies that the superimposition of the shares represents the Boolean OR function. The last column in Figure given below shows the resulting sub-

18 pixel when the sub-pixels of both the shares in the third and fourth columns are superimposed.

Fig 2.i An example of two-out-of-two VC scheme.

2.9 K-N SECRET SHARING SCHEME

In (2, 2) visual cryptography, both the shares are required to reveal secret information. Due to some problem if one share gets lost then the secret information cannot be revealed. So, there is a restriction of keeping all the shares secure to reveal the secret information and user cannot afford to lose a single share. Naor and Shamir generalized basic model of visual cryptography into a visual variant of k out of n visual cryptography scheme to give some flexibility to user. In (k, n) visual cryptography scheme, n shares can be generated from original image and distributed. Original image is recognizable only if k or more shares superimposed, where value of k is between 2 to n. If less than k shares stacked together, secret original image cannot be revealed. It gives flexibility to user. If user loses some of the shares still secret information can be revealed, if minimum k number of

19 shares is obtained. It also ensures the security as to know the secret information you have to have more than k shares out of n secret shares.

In k out of n visual cryptography scheme is a type of cryptographic technique where a digital image is divided into n number of shares by cryptographic computation. In the decryption process only k or more than k number of shares can reveal the original information [Here can form the original image]. Less than k number of shares can not reveal the original information.

In this project we made use of this algorithm in which we divide a digital color image into n number of shares where minimum k numbers of shares are sufficient to reconstruct the image. If k numbers of shares are taken then the remaining shares are (n−k). In an image if certain position of a pixel is 1, then in (n−k)+1 number of shares in that position of that pixel there will be 1. In the remaining shares in that position of the pixel there will be 0. A random number generator is used to identify those (n−k)+1 number of shares.

2.10 EXISTING SYSTEMS

All this had been started by Naor and Shamir where they proposed the idea of k out of n secret sharing algorithm. This model assumes that the secret message is a collection of black and white pixels and each pixel is handled separately. Each original pixel can appear in ‘n’ modified versions called shares. Each pixel in original image is represented by a collection both while and black subpixels, which are printed close to each other on transparencies. This model only works for black and white images. Later, this process was implemented by two-out-of-two secret sharing scheme where the secret image was divided into only 2 shares, and we need both of them to reconstruct the original image. This same scheme was used to get a new color by making use of 2 different colors (the resultant color is not same as either of the 2 colors that are stacked one over the other). Now in k-n secret sharing scheme, when a min of ‘k’ shares is brought together and stacked one above the other, it gives out the original or secret image. Later, this idea had been improved and made simple by using a random number generator. A reconstruction factor is first calculated(n-k+1). Now each pixel of the original image is put in (n-k+1)

20 shares. This is done for a surety that no pixel of the original image gets missed when we select k shares out of the n shares. Human visual system acts as an OR function. So, having that pixel in at least one of the k shares is enough to have that pixel in the output. This algorithm works for black and white as well as RGB images.

21

3. METHODOLOGY

Based on the above literature survey, we finally decided to implement this project by making use of an efficient yet an easy algorithm: k-n Secret Sharing Algorithm by making use of a Random Number Generator. Not only that this algorithm is easy to implement, but it is also efficient to do so. Since, the data that army works on should be transmitted securely and the data is really sensitive, we are also making use of a public key and a private key encryption technique. Now, even if the data that is being transmitted is tapped by a third party, they won’t be able to deduce anything from that image as its a share that is encrypted twice. Only if he/she has enough number of shares with exactly correct keys will he able to get the secret.

This approach has the following steps:

1. An image that is to be secretly transmitted should be selected. 2. This selected image will then be encrypted, 2.1 First by using Caesar cipher wherein we make use of a key and compute a value. Then we add this value to all the pixels and mod it by 256. 2.2 Then we use RSA encryption wherein we compute a pair of public and private keys. Now with this public key, we encrypt all the pixel values using RSA. 3. Then we split this encrypted image into ‘n’ shares using [3] (k, n) secret sharing encryption algorithm. 4. Then we send each share to each individual person via mails. 5. Now, at least ‘k’ of ‘n’ shares are selected for merging. 6. Once the shares are selected, then we overlap and combine these shares using [3] (k, n) secret sharing decryption algorithm. 7. Once we got the merged image, then it is time to carefully decrypt the merged image. 7.1 The decryption starts by decrypting using RSA. The private key that we generated earlier is used for RSA decryption. 7.2 Next, we make use of the key (that we earlier used for Caesar Cipher encryption) for decrypting using Caesar Cipher.

22

This order must match with the reverse order in which encryption is done. If first encryption is Caesar Cipher, in decryption using Caesar Cipher has to be done last.

8. We will have the final image.

Finally, after all these steps we will be able to get the original secret image.

3.1 PROPOSED SYSTEM

Our proposed system will be having the following main modules.

1. Get the original image and encrypt the original image. 2. Split/divide this encrypted image into ‘n’ shares. 3. Send (via mail) each share to each of ‘n’ people/shareholders. 4. Collect at least ‘k’ shares from those ‘n’ people/shareholders (k ≤ n) and merge all of them. 5. Decrypt the resultant image by making use of right keys.

3.1.1 SYSTEM ARCHITECTURE

Fig 3.a System Architecture

23

The flow of the system architecture goes like this,  A secret image is selected so that it can be transmitted securely.  That image is then encrypted first by using a private key or symmetric key encryption technique (Caesar Cipher) and then by a public key or asymmetric key encryption technique (RSA). (The order and the cryptographic algorithms can be different)  Now this resultant image is then divided into ‘n’ shares by using k-n secret sharing algorithm by using a random number generator and also by using a reconstruction factor (n-k+1).  Now each of these ‘n’ shares is sent to each of ‘n’ different people/shareholders via mails by the admin.  Now, to reconstruct the original image, at least ‘k’ out of the shareholders has to agree to combine their shares. Now, since they have agreed to combine their shares, each of these shareholders (at least ‘k’ people) will have to send back their shares to the admin.  Admin on getting the shares back, will combine the shares.  Now, the admin has a resultant image which he/she will have to decrypt.  In the decryption phase, the resultant image is first decrypted w.r.t RSA decryption algorithm and then by Caesar Cipher decryption algorithm with the proper keys.  If all the conditions of minimum number of shares required and the use of correct keys are satisfied, the admin will have the secret image by now.  Now, the secret image can be seen by the shareholders who have accepted to merge their shares directly at the admin’s system.

This is how our proposed algorithm works in brief.

24

3.1.2 MODULES

At first, an image that is to be transmitted as a secret has to be selected. From there on these are the modules that are being proposed.

3.1.2.1 Encryption

Encryption is that process where the data is transformed into an incomprehensible data that is not in its original format. Encryption is necessary to provide more security to the secret that is being transmitted so that even the shares are taken by the intruders, they cannot form the secret back to its original form. In this project, we make use of 2 encryption algorithms: first one is a simple and easy symmetric encryption algorithm Caesar Cipher where in every value in each pixel is added with a fixed value(key) and then mod with 256 because every value in a pixel is in the range of 0-255, the next encryption used is a stronger algorithm RSA which makes use of two pairs of keys(public and private).Two encryption algorithms are used to make the security much stronger.

Algorithms and Working of Encryption techniques used  Caesar Cipher The Caesar Cipher technique is one of the earliest and simplest method of encryption technique. It’s simply a type of substitution cipher, i.e., each letter of a given text is replaced by a letter some fixed number of positions down the alphabet. For example, with a shift of 1, A would be replaced by B, B would become C, and so on. The method is apparently named after Julius Caesar, who apparently used it to communicate with his officials. Thus, to cipher a given text we need an integer value, known as shift which indicates the number of positions each letter of the text has been moved down.

25

In this project, the key is calculated by adding all the ASCII values of the key(text) that is entered. We get a value here which is added to each of R, G, B values of every pixel and then mod it with 256 since a value in each pixel would be in the range of 0, 1, ….., 255. By now we will have an image that is encrypted by Caesar Cipher. Since this algorithm is easy to crack, we make use of RSA as well. The formula used to encrypt is: 퐶(푥) = (퐼(푥) + 푘푒푦)푚표푑 256 Where, C is the encrypted Image and I is the Original Image, x is a specific pixel, key is the sum of all ASCII values of each character in the key that is entered.

 RSA RSA is algorithm used by modern computers to encrypt and decrypt messages. It is an asymmetric cryptographic algorithm, means there are two different keys. This is also called public key cryptography because one of them is public i.e., can be given to everyone. The other key must be kept private. It is based on the fact that finding the factors of a integer is hard. RSA stands for Ron Rivest , Adi Shamir and Leonard Adleman , who first publicly described it in 1978. RSA involves a public key and private key. The public key can be known to everyone, it is used to encrypt messages. Messages encrypted using the public key can only be decrypted with the private key. The keys for the RSA algorithm are generated the following way: - 1. Choose two distinctive prime numbers p and q. For security purpose, the integers p and q should be chosen at random and should be of similar bit length. Prime integers can be efficiently found using a primality test. 2. Compute n = p * q

26

n is used as the modulus for both the public and private keys. It's length usually expressed in bits, is the key length. 3. Compute Φ(n) = Φ (p) * Φ (q) = (p - 1) * (q - 1) = n - (p + q - 1) where, Φ (n) is Euler's totient function. 4. Choose an integer e such that, 1

In the encryption process, one party transmits public key (n, e) to second party and keeps the private key d secret. The second party then wishes to send message M to first party. The second party first turns M into an integer m such that, 0

Time Complexity for Encryption:

1) Caesar Cipher Encryption: O(row*column*3) 2) RSA Encryption: O(row*column*3*log(e))

27

Fig 3.b Encryption and Division into ‘n’ shares

3.1.2.2 Division into ‘n’ shares (Division into ‘n’ shares)

The encrypted image is used to perform share generation where the shares of the image is generated using (k-n) secret sharing algorithm. This algorithm as name suggests makes use of n and k values to generate the shares of the image. In this algorithm a number of matrices equal to ‘n’ are created. Now each RGB value in each pixel is placed in any random (n-k +1) number of matrices. As a result, each matrix does not hold information about all RGB values of pixels and at the same time holds enough information to be a share. After all the RGB values are placed now shares are generated based on these matrices. Algorithm An image is taken as input. The number of shares the image would be divided (n) and number of shares to reconstruct the image (k) is also taken as input from user. The encryption, i.e. division of the image into n number

28 of shares such that k numbers of shares are sufficient to reconstruct the image; is done by the following algorithm. Step: I: Take an image as input and calculate its width (w) and height (h). Step II: Take the number of shares (n) and minimum number of shares (k) to be taken to reconstruct the image. k must be less than or equal to n. Step III: Calculate recons=(n-k)+1. Step IV: Create a three dimensional array img_share[n][w*h][32] to store the pixels of n number of shares. Step V: for i=0 to (w*h-1) { Scan each pixel value of the image and convert it into 32 bit binary string let PIX. for j=0 to 31 { if ith position of PIX contains ‘1’ call Random_Place(n, recons) for k=0 to (recons-1) { Set img_share[rand[k]][i][j] = 1 } } } Step VI: Create a one dimensional array img_cons[n] to store constructed pixels of each share. Step VII: for k1=0 to(n-1) { for k2=0 to (w*h-1) {

29

String value= “” for k3=0 to 31 { value=value+img_share[k1][k2][k3] } construct alpha, red, green and blue part of each pixel by taking consecutive 8 bit substring starting from 0. Construct pixel from these part and store it into img_cons[k1] } generate image from img_cons[k1] }

subroutine int Random_Place(n,recons) { create an array rand[recons] to store the random number generated. for i=0 to (recons-1) { generate a random number within n, let rand_int if(rand_int is not in rand[recons]) rand[i] = rand_int. } return rand[recons] }

Time Complexity for Division into ‘n’ shares:

1) Division into N-Shares: O(row*column*(N-K+1))

30

3.1.2.3 Generate and Send e-mails to each shareholder

Emails are sent to user’s emails provided by admin. Here each user would be an army officer who are required to make a decision. The number of emails is equal to number of shares created at the first place. Now, each user will get a share of the secret image. E-mails are sent directly by a python code by making use of the modules smtplib, MIMEMultipart, MIMEText, MIMEBase and by entering the e-mail ids of each shareholder after those shares are generated.

3.1.2.4 Overlapping ‘k’ shares (Merging ‘k’ shares)

To reconstruct the image from n shares, at least k shares of those n shares are definitely required. Even though the knowledge of k-1 shares cannot form the original image. Now if at least k out of n shareholders accept to contribute their shares, then the image can be reconstructed. Image is constructed from these shares based on OR operation so that every non-zero pixel is considered and used for image construction. As a result, the image is ready for decryption. Algorithm In the case of visual cryptography, decryption is done by human visual system. It is already discussed that human visual system acts as an OR function. In the case of decryption, for computer generated program; OR function can be used. Here the numbers of shares are taken as input from user. As the shares are created from the image taken as input in encryption algorithm, each share must be of equal height and width as the source image. Then bitwise OR operation is performed among pixels of the shares, and final pixel values are stored in an array. The decryption algorithm is as follows. Step I: Input number of shares to be taken (k), height (h) and width (w) of each share.

31

Step II: Create a two dimensional array share[k][w*h] to store the pixel values of each share. Create a one dimensional array final[w*h] to store the final pixel values of the image to be produced by performing OR operation. Step III: for i=0 to k-1 { input the name of the ith image share to be taken. for j=0 to (w*h-1) { Scan each pixel value of the ith image share and store the value in share[i][j]. } } Step IV: for i=0 to (k-1) { for j=0 to (w*h - 1) { final[j]=final[j] | share[i][j]; [ | is bitwise OR] } } Step V: Generate image from final[w*h].

Time Complexity for Merging ‘k’ shares:

Overlapping K-Shares: O(K*row*column*3)

32

Fig 3.c Merging at least ‘k’ shares and Decryption

33

3.1.2.5 Decryption

The image reconstructed from shares is decrypted in this module. The reconstructed image is first decrypted using RSA algorithm. Now the resultant is then decrypted with a key using Caesar Cipher. These keys must be same or related to the ones that are used during encryption. Wrong key won’t give us the original image back and secret won’t be revealed properly. The order in which we use the decryption algorithms is very important. Since we encrypted the image first by Caesar Cipher and then by RSA, in the decryption process we should first decrypt the image by using RSA decryption algorithm and by then that of Caesar Cipher. If the order of encryption and decryption aren’t exactly opposite of each other, the final image will not be same as the original image. Also, the keys used to decrypt the image has to be exactly correct to get a correct image by the end.

Fig 3.d Order of Encryption and Decryption

34

Algorithms and Working of Decryption techniques used  RSA RSA involves a public key and private key. The public key can be known to everyone, it is used to encrypt messages. Messages encrypted using the public key can only be decrypted with the private key. The keys for the RSA algorithm are generated the following way: - 1. Choose two distinctive prime numbers p and q. For security purpose, the integers p and q should be chosen at random and should be of similar bit length. Prime integers can be efficiently found using a primality test. 2. Compute n = p * q n is used as the modulus for both the public and private keys. It's length usually expressed in bits, is the key length. 3. Compute Φ(n) = Φ (p) * Φ (q) = (p - 1) * (q - 1) = n * (p + q - 1) where, Φ (n) is Euler's totient function. 4. Choose an integer e such that, 1

In the decryption process, the first party can recover m from C by using private key exponent d via computing m=Cd (mod n) given m, first party can never recover the original message M by reversing the padding scheme.

35

 Caesar Cipher The Caesar Cipher technique is one of the earliest and simplest method of encryption technique. It’s simply a type of substitution cipher, i.e., each letter of a given text is replaced by a letter some fixed number of positions down the alphabet. For example, with a shift of 1, A would be replaced by B, B would become C, and so on. The method is apparently named after Julius Caesar, who apparently used it to communicate with his officials. Thus, to cipher a given text we need an integer value, known as shift which indicates the number of positions each letter of the text has been moved down. In this project, the key is calculated by adding all the ASCII values of the key(text) that is entered. We get a value here which is added to each of R, G, B values of every pixel and then mod it with 256 since a value in each pixel would be in the range of 0, 1, ….., 255. By now we will have an image that is encrypted by Caesar Cipher. Since this algorithm is easy to crack, we make use of RSA as well. The formula used to decrypt is: 퐹(푥) = (퐶(푥) − 푘푒푦)푚표푑 256

Where, C is the encrypted Image and F is the Final Image, x is a specific pixel, key is the sum of all ASCII values of each character in the key that is entered and the key has to be the same one that is used in encryption.

Time Complexity for Decryption:

1) Caesar Cipher Decryption: O(row*column*3) 2) RSA Decryption: O(row*column*3*log(d))

36

4. EXPERIMENTAL ANALYSIS AND RESULTS

4.1 SYSTEM CONFIGURATION

4.1.1 Software Configurations

These are the Software Configurations that are required.

 Operating System: Windows 10/8/7 (incl. 64-bit), Mac OS, Linux  Language: Python 3  IDE: JetBrains PyCharm Community Edition 2019.1.3 x64  Framework: Django 3

4.1.2 Hardware Configurations

These are the minimum Hardware configurations that are required.

 Processor: Intel Atom processor or Intel Core i3 processor.  RAM: 1 to 3 GB.  HDD: 512 GB or higher  Monitor: 1024 x 768 minimum screen resolution.  Keyboard: Standard Keyboard

37

4.2 SAMPLE CODE

 Reading an Image

from PIL import Image

im=Image.open(image_name)

 Caesar Cipher Encryption def encryptImage(result,key): k=0 for i in key: k+=ord(i) l=len(result) for i in range(l): for j in range(3): result[i][j]=(result[i][j]+k)%256 return result

 Calculate ‘e’ in RSA (public key used for encryption) def get_e(p,q,fn): e=1 for i in range(2,fn): if(gcd(fn,i)==1 and (i!=p and i!=q)): e=i return e

def gcd(a,b): if b==0: return a else:

38

return gcd(b,a%b)

return 0  RSA Encryption def rsa_encryption(new_list,e,n): print("Encryption...... ") enc_list=[] for i in range(len(new_list)): r = enc(new_list[i][0], e, n) g = enc(new_list[i][1], e, n) b = enc(new_list[i][2], e, n) enc_list.append((r,g,b))

print("Encryption done.....") return enc_list

def enc(m,e,n): return pow(m,e,n)

 Divide into ‘n’ Shares n_share = [[[0,0,0] for col in range(total_pix)] for row in range(no)] for i in range(total_pix): a = list(range(no)) size = no for h in range(recons): r = random.choice(a) ind = a.index(r) a[ind] = a[size - 1] n_share[r][i]=pix_val[i]

for i in range(no):

39

im = Image.new("RGB", (width, height)) pix = im.load() name=iname+str(i+1)+".png" index=0 for j in range(height): for k in range(width): r = n_share[i][index][0] g = n_share[i][index][1] b = n_share[i][index][2] pix[k,j] = (r,g,b) index+=1 im_name="C:/Users/hp/PycharmProjects/finalyear/static/images/N_Shares /"+name im.save(im_name) im_name="images/N_Shares/"+name if email_id_index_temp

40

 Send Mails import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from email.mime.base import MIMEBase from email import encoders import csv

class Email_Sender: def __init__(self): self.email = "[email protected]" self.password = "imageshare2020@anits"

# All code in __init__ is taken from stack overflow self.server = smtplib.SMTP('smtp.gmail.com', 587) # 587 is port no of smtp self.server.ehlo() # stolen code self.server.starttls() # stolen code self.server.login(self.email, self.password) # login

def send_email(self, to_email_id, share_path): mail = MIMEMultipart() # MIME because image and text are present. dict() returned mail['From'] = self.email # from email mail['To'] = to_email_id # to email mail['Subject'] = "Your Share Of Image" # Subject

message = ("Dear Share Holder,", "Your Share Of Image is Attached ,If you agree mailback Image to Admin") body = "\n\n".join(message) # Creating body of message

41

mail.attach(MIMEText(body, 'plain')) # Attach the body as plain text to mail. mail is MIMEMultipart()

attachment_name = share_path.split('/')[-1] # extracting last part in the path to get filename attachment = open(share_path, "rb") # reading file in rb mode to preserve image nature

part = MIMEBase('application', 'octet-stream') # MIME base with octet stream is default part.set_payload((attachment).read()) # setting the payload with attachment encoders.encode_base64(part) # encoding the image to octect stream part.add_header('Content-Disposition', "attachment; filename= %s" % attachment_name)

mail.attach(part) # attaching image to original email text = mail.as_string() # get stringified mail

self.server.sendmail(self.email, to_email_id, text) # send email

 Merging ‘k’ Shares def mergeToKShare(k_image,k_share,d,n,decrypt_key): k=int(k_share) kth=1 width=0 height=0 total_len=0 result=[] index=0 while kth<=k:

42

kth_image_name=k_image[index] index+=1

if kth==1: im = Image.open(kth_image_name) result = list(im.getdata()) width, height = im.size total_len=width*height for i in range(total_len): result[i]=list(result[i]) else: im=Image.open(kth_image_name) kth_image=list(im.getdata()) for i in range(total_len): r = kth_image[i][0] g = kth_image[i][1] b = kth_image[i][2] result[i][0] = result[i][0] or r result[i][1] = result[i][1] or g result[i][2] = result[i][2] or b

kth+=1 dec_img = Image.new("RGB", (width, height))

43

 Calculate ‘d’ in RSA (private key used for decryption) def get_d(e,fn): d=inverse_mod(e,fn) return d

def inverse_mod(a,b): for i in range(1,b): if a*i%b==1: return i return 0

 RSA Decryption def rsa_decryption(enc_list,d,n): print("Decryption...... ") dec_list=[] for i in range(len(enc_list)): r=dec(enc_list[i][0], d, n)%n g=dec(enc_list[i][1], d, n)%n b=dec(enc_list[i][2], d, n)%n dec_list.append([r,g,b])

print("Decryption Done.....") return dec_list

def dec(c,d,n): return pow(c, d, n)

44

 Caesar Cipher Decryption def decryptImage(result,key): k=0 for i in key: k+=ord(i) l=len(result) for i in range(l): for j in range(3): result[i][j]=(result[i][j]-k)%256 return result

 Rendering all the HTML pages from django.views import View from django.shortcuts import render,redirect from imageshare.e import * from imageshare.d import * from imageshare.rsa import *

p,q=1,1 n=1 fn=0 e,d=0,0 class renderHomePage(View): def get(self,request): return render( request, template_name='imageshare/index.html' ) class renderEncryptPage(View): def get(self,request): return render(

45

request, template_name='imageshare/encryptPage.html' )

def post(self,request): if request.POST.get('home'): return render(request,template_name='imageshare/index.html')

image_name = request.POST['pic'] print(image_name) file_name=image_name image_name = 'C:/Users/hp/PycharmProjects/finalyear/static/images/Input_Image/'+image_name n_share = request.POST['n_shares'] k_share = request.POST['k_shares'] encrypt_key = request.POST['user_key']

p=int(request.POST['p']) q=int(request.POST['q']) n=p*q

fn=(p-1)*(q-1) e=get_e(p,q,fn) d = get_d(e, fn) email_id = request.POST['mail_ids'] email_id_list=email_id.split("\r\n") file_loc="C:/Users/hp/PycharmProjects/finalyear/Reference_Files/"+file_name[:- 4]+".txt" f=open(file_loc,'w+') f.write(str(p)+","+str(q)+","+str(n)+","+str(fn)+","+str(e)+","+str(d)+"\n")

46

f.write("("+n_share+","+k_share+")"+","+encrypt_key) f.close() n_images=divideToNShare(image_name, n_share, k_share, encrypt_key,e,n,email_id_list)

return render( request, template_name='imageshare/n_shares.html', context={'n_images': n_images,} )

class renderDecryptPage(View): def get(self,request): return render( request, template_name='imageshare/decryptPage.html' )

def post(self,request): form=request.POST k_share = request.POST['k_value'] decrypt_key = request.POST['decrypt_pass'] path="C:/Users/hp/PycharmProjects/finalyear/static/images/N_Shares/" #d=get_d(e,fn) d=int(request.POST['d_value']) n=int(request.POST['n_value']) k_image=[] for file in request.FILES.getlist('k_image'): k_image.append(path+str(file))

47

merged_image=mergeToKShare(k_image,k_share,d,n,decrypt_key) return render( request, template_name='imageshare/mergedImage.html', context = {'merged_image': merged_image, } )

48

4.3 SCREENSHOTS AND OUTPUTS

First, we will have a look at our projects User Interface. These are the HTML pages.

Fig 4.a Home Page

49

Fig 4.b Encryption and Dividing into ‘n’ Shares Page

Fig 4.c Page after encryption and dividing into ‘n’ shares: also shows which share is sent to which e-mail address.

50

Fig 4.d Merging ‘k’ Shares and Decryption Page

Fig 4.e Output Page (when there are at least required number of ‘k’ shares and keys of both RSA and Caesar Cipher are correct).

51

Fig 4.f Output Page (when there are at least required number of ‘k’ shares and key RSA is wrong and key of Caesar Cipher is correct).

Fig 4.g Output Page (when there are at least required number of ‘k’ shares and key RSA is correct and key of Caesar Cipher is wrong).

52

Fig 4.h Output Page (when there are less than required number of ‘k’ shares and keys of both RSA and Caesar Cipher are correct or wrong).

Fig 4.i Data Set that is worked on

53

Now let’s see the different phases of an image through out our project

Fig 4.j Original Input Image

Fig 4.k Encrypted Image

(key in CC: god

Key in RSA: p=89,q=97,e=5,d=5069,n=8633)

54

Fig 4.l ‘n’ Shares of the Input Image

(n=5, k=4)

55

Fig 4.m Image obtained after merging at least ‘k’ shares (here 4 shares are taken)

Fig 4.n Image obtained after merging less than ‘k’ shares (here 3 shares are taken) and before decrypting

56

Consider the case where at least ‘k’ shares are merged. Then,

Fig 4.o Output Image obtained when both the keys are correct

Fig 4.p Output Image obtained when only the decryption key used in Caesar Cipher is Wrong

57

Fig 4.q Output Image obtained when only the decryption key used in RSA is Wrong.

Now consider the case when there aren’t enough number of shares combined(less than ‘k’ shares).

Fig 4.r Output Image obtained when less than ‘k’ shares are combined.

58

4.4 EXPERIMENTAL ANALYSIS

Jung-San Lee et.al suggested security, element enlargement, accuracy and procedure quality as a performance measures. Security is glad if every share reveals no info of the initial image and also the original image can't be reconstructed if their square measure fewer than k shares collected. Accuracy is taken into account to be the standard of the reconstructed secret image and evaluated by peak signal-to-noise (PSNR) live. Procedure quality considerations the full variety of operators needed each to get the set of n shares and to reconstruct the initial secret image.

File Name Resolution Encryption Time (in Decryption Time (in (w*h) sec) sec) anits.png 200*200 0.2362 0.3569 download.jpg 225*225 0.2951 0.4969

Flower.jpg 159*119 0.1234 0.1837

god.png 450*450 1.1775 2.1045

human.jpg 208*243 0.2957 0.4895

map.jpg 300*168 0.3117 0.4938

mona.png 256*256 0.4669 0.6476

tulip.png 173*292 0.2989 0.4882

Table 4.a: RSA Encryption and Decryption times for images with different resolutions.

59

File Name Resolution Encryption Time (in Decryption Time (in (w*h) sec) sec) anits.png 200*200 0.1333 0.0980 download.jpg 225*225 0.1310 0.1270

Flower.jpg 159*119 0.0474 0.0677

god.png 450*450 0.6036 0.5164

human.jpg 208*243 0.1475 0.1214

map.jpg 300*168 0.1162 0.1286

mona.png 256*256 0.1364 0.1672

tulip.png 173*292 0.1157 0.1402

Table 4.b: Caesar Cipher Encryption and Decryption times for images with different resolutions.

File Name Resolution Time taken for dividing Time taken for combining (w*h) Image into ‘n’ shares ‘k’ shares to form the Image (in sec) (n=5) (in sec) (k=4)

anits.png 200*200 2.3271 0.3847 download.jpg 225*225 2.7729 0.4426

Flower.jpg 159*119 1.8608 0.1910

god.png 450*450 6.3979 1.9212

human.jpg 208*243 2.6610 0.4559

map.jpg 300*168 2.6496 0.4583

mona.png 256*256 2.9356 0.6124

tulip.png 173*292 2.6486 0.4697

Table 4.c: Time taken for Dividing an Image into ‘n’ shares and Combining ‘k’ shares to form an Image for images with different resolutions (n=5.k=4).

60

Peak Signal to Noise Ratio (PSNR) is the ratio between the maximum possible power of an image to that of the power of corrupting noise that affects the quality of its representation.

(퐿 −1) 푃푆푁푅 = 10푙표푔 푀푆퐸 where, L in the maximum intensity level.

Mean Squared Error (MSE) is defined as follows,

1 푀푆퐸 = (푂(푖, 푗) − 퐷(푖, 푗)) 푚푛 where, O is the original image and D is the resultant image.

The image that is being recovered (by using the above method) after merging properly and decrypting properly is same as that of the original image and it is noise free. If at all, something is not done properly there will be noise and value of PSNR is computed by using the above formulae.

If MSE is zero, then there is no noise in the original image.

PSNR Values when comparing:

 Fig 4.j and Fig 4.o: 100 dB (no noise added)  Fig 4.j and Fig 4.p: 42.11020369539948 dB  Fig 4.j and Fig 4.q: 27.348883827519536 dB  Fig 4.j and Fig 4.r: 27.972373933912806 dB

61

5. CONCLUSION AND FUTURE WORKS

5.1 CONCLUSION

Sharing data secretly, especially in the domain of army is very important. That data that is being transmitted is very sensitive. So, it is very important to transmit data by providing security to it. This idea not only makes it difficult for intruders to steal the data but also makes it nearly impossible as we encrypt the data before dividing into shares. Encryption provides extra security for the data in addition to that data being divided into shares. Now even if the intruder has required number of shares, he won’t be able to get the original image as it is as he doesn’t know the values of the key. What makes this algorithm good is that, the intruder has to get all the required number of shares at the first place and this is tough. What is tougher is that even if he has the required number of shares, he should have the key values as well. So, it’s better if the value of ‘k’ to be closer to the value of ‘n’ and also have a good set of keys for encryption.

5.2 FUTURE WORKS

This proposed method has a compulsion that there should be only one admin and each shareholder have to take the shares from and has to bring back the shares to that only admin. It is that person who initially takes the image to be shared secretly, encrypt the image, divide into ‘n’ shares, send mails, combine the accepted shares, decrypt the image, get back the secret image and maintain all the files related to that image. It can be further extended in such a way that encryption, division into ‘n’ shares and mailing those shares be done at one end taken care by one admin and combining ‘k’ shares and decryption be done at another end taken care by another admin. This makes this algorithm more feasible and robust to use and work with. Also, with the changing technologies, newer and stronger encryption algorithms can replace the ones that are used in this proposed algorithm.

This same idea can be used in other fields as well like in providing authentication in Photography Contests, Online Voting Systems using Visual Cryptography, in Copyright authentication etc. This idea can further be made strong by making use of much stronger cryptographic algorithms.

62

Visual Cryptography technique is used to protect image-based secret information. In this scheme we have proposed a technique called random sequence to divide an image into n number of shares. The shares are sent through different communication channels from sender to receiver so that the probability of getting sufficient shares by the intruder minimizes.

But the distorted shares may arise suspicion to the hacker's mind that some secret information is passed. The original image can be encrypted using a key to provide more security to this scheme. The key may be a text or a small image.

Steganography can be used by enveloping the secret shares within apparently innocent covers of digital picture. This technique is more effective in providing security from illicit attacks.

63

REFERENCES

1. Adi Shamir “Communications of the ACM: How to Share a Secret” Volume 22, Issue 11 Nov. 1979.

2. J. Sharmila, Jagadish Gurrala “A Novel Approach on Secure Data Transfer for General Transactions using Secret Sharing Scheme” International Journal of Computer Applications (0975 – 8887) Volume 172 – No.8, August 2017. 3. Shyamalendu Kandar, Arnab Maiti “K-N SECRET SHARING VISUAL CRYPTOGRAPHY SCHEME FOR COLOR IMAGE USING RANDOM NUMBER” International Journal of Engineering Science and Technology (IJEST). 4. Moni Naor, Adi Shamir “Visual Cryptography” (The preliminary version of this paper appeared in Eurocrypt 94). 5. A. Kalai Selvi, Dr. M. Mohamed Sathik, “Polynomial Based Secret Sharing Scheme for Image Encryption Based on Mathematical Theorem” Volume 2, No. 1, Jan-Feb 2011 International Journal of Advanced Research in Computer Science 6. Image Security using Visual Cryptography: A thesis submitted by Sangeeta Bhuyan, NIT Rourkela. 7. Debashmita Poddar “(2, N) VISUAL CRYPTOGRAPHIC SCHEME FOR BLACK AND WHITE PIXELS USING SQUARE MATRICES” INDIAN STATISTICAL INSTITUTE, Kolkata, July 2016. 8. 4th International Conference on Eco-friendly Computing and Communication Systems, ICECCS 2015. Sharing a Secret Image with Encapsulated Shares in Visual Cryptography, Shankar K, Eswaran P. 9. M. Naor and A. Shamir, “Visual cryptography,” Advances in Cryptology- Eurocrypt‟94, pp. 1–12, 1995. 10. Jonathan Weir; WeiQi Yan - Visual Cryptography and Its Applications.

64

APPENDIX

DJANGO

Django is a high-level Python web framework that enables rapid development of secure and maintainable websites. Built by experienced developers, Django takes care of much of the hassle of web development, so you can focus on writing your app without needing to reinvent the wheel. It is free and open source, has a thriving and active community, great documentation, and many options for free and paid-for support.

WHAT DOES DJANGO CODE LOOK LIKE?

In a traditional data-driven website, a web application waits for HTTP requests from the web browser (or other client). When a request is received the application works out what is needed based on the URL and possibly information in POST data or GET data. Depending on what is required it may then read or write information from a database or perform other tasks required to satisfy the request. The application will then return a response to the web browser, often dynamically creating an HTML page for the browser to display by inserting the retrieved data into placeholders in an HTML template.

Django web applications typically group the code that handles each of these steps into separate files:

• URLs: While it is possible to process requests from every single URL via a single function, it is much more maintainable to write a separate view function to handle each resource. A URL mapper is used to redirect HTTP requests to the appropriate view based on the request URL. The URL mapper can also match particular patterns of strings or digits that appear in a URL and pass these to a view function as data.

• View: A view is a request handler function, which receives HTTP requests and returns HTTP responses. Views access the data needed to satisfy requests via models, and delegate the formatting of the response to templates.

65

• Models: Models are Python objects that define the structure of an application's data, and provide mechanisms to manage (add, modify, delete) and query records in the database.

• Templates: A template is a text file defining the structure or layout of a file (such as an HTML page), with placeholders used to represent actual content. A view can dynamically create an HTML page using an HTML template, populating it with data from a model. A template can be used to define the structure of any type of file; it doesn't have to be HTML!

A few of the other things provided by Django include:

• Forms: HTML Forms are used to collect user data for processing on the server. Django simplifies form creation, validation, and processing.

• User authentication and permissions: Django includes a robust user authentication and permission system that has been built with security in mind.

• Caching: Creating content dynamically is much more computationally intensive (and slow) than serving static content. Django provides flexible caching so that you can store all or part of a rendered page so that it doesn't get re-rendered except when necessary.

• Administration site: The Django administration site is included by default when you create an app using the basic skeleton. It makes it trivially easy to provide an admin page for site administrators to create, edit, and view any data models in your site.

• Serializing data: Django makes it easy to serialize and serve your data as XML or JSON. This can be useful when creating a web service (a website that purely serves data to be consumed by other applications or sites, and doesn't display anything itself), or when creating a website in which the client-side code handles all the rendering of data.

66

Fig app1 Structure of Django

67

DJANGO HELPS YOU TO WRITE SOFTWARE THAT IS:

 Complete

Django follows the "Batteries included" philosophy and provides almost everything developers might want to do "out of the box". Because everything you need is part of the one "product", it all works seamlessly together, follows consistent design principles, and has extensive and up-to-date documentation.

 Versatile

Django can be (and has been) used to build almost any type of website — from content management systems and wikis, through to social networks and news sites. It can work with any client-side framework, and can deliver content in almost any format (including HTML, RSS feeds, JSON, XML, etc). The site you are currently reading is built with Django!

Internally, while it provides choices for almost any functionality you might want (e.g. several popular databases, templating engines, etc.), it can also be extended to use other components if needed.

 Secure

Django helps developers avoid many common security mistakes by providing a framework that has been engineered to "do the right things" to protect the website automatically. For example, Django provides a secure way to manage user accounts and passwords, avoiding common mistakes like putting session information in cookies where it is vulnerable (instead cookies just contain a key, and the actual data is stored in the database) or directly storing passwords rather than a password hash.

A password hash is a fixed-length value created by sending the password through a cryptographic hash function. Django can check if an entered password is correct by running it through the hash function and comparing the output to the stored hash value. However due to the "one-way" nature of the function, even if a

68

stored hash value is compromised it is hard for an attacker to work out the original password.

Django enables protection against many vulnerabilities by default, including SQL injection, cross-site scripting, cross-site request forgery and clickjacking (see Website security for more details of such attacks).

 Scalable

Django uses a component-based “shared-nothing” architecture (each part of the architecture is independent of the others, and can hence be replaced or changed if needed). Having a clear separation between the different parts means that it can scale for increased traffic by adding hardware at any level: caching servers, database servers, or application servers. Some of the busiest sites have successfully scaled Django to meet their demands (e.g. Instagram and Disqus, to name just two).

 Maintainable

Django code is written using design principles and patterns that encourage the creation of maintainable and reusable code. In particular, it makes use of the Don't Repeat Yourself (DRY) principle so there is no unnecessary duplication, reducing the amount of code. Django also promotes the grouping of related functionality into reusable "applications" and, at a lower level, groups related code into modules (along the lines of the Model View Controller (MVC) pattern).

 Portable

Django is written in Python, which runs on many platforms. That means that you are not tied to any particular server platform, and can run your applications on many flavors of Linux, Windows, and Mac OS X. Furthermore, Django is well-

69 supported by many web hosting providers, who often provide specific infrastructure and documentation for hosting Django sites.

70

tion) and in which nonmechanical solutions (which manipulate this data) are also allowed. Our goa ! is to divide D into n pieces D, ..... D n in such a way that: (1) knowledge of any k or more D i pieces makes D Programming R. Rivest easily computable; Techniques Editor (2) knowledge of any k- 1 or fewer Di pieces leaves D completely undetermined (in the sense that all its How to Share a Secret possible values are equally likely). Such a scheme is called a (k, n) threshold scheme. Adi Shamir Efficient threshold schemes can be very helpful in the Massachusetts Institute of Technology management of cryptographic keys. In order to protect data we can encrypt it, but in order to protect the encryp- tion key we need a different method (further In this paper we show how to divide data D into n change the problem rather than solve it). The most pieces in such a way that D is easily reconstructable secure key management scheme keeps the key in a single, from any k pieces, but even complete knowledge of well-guarded location (a computer, a human brain, or a k - 1 pieces reveals absolutely no information about D. safe). This scheme is highly unreliable since a single This technique enables the construction of robust key misfortune (a computer breakdown, sudden death, or management schemes for cryptographic systems that sabotage) can make the information inaccessible. An ob- can function securely and reliably even when misfor- vious solution is to store multiple copies of the key at dif- tunes destroy half the pieces and security breaches ex- ferent locations, but this increases the danger of security pose all but one of the remaining pieces. breaches (computer penetration~ betrayal, or human er- Key Words and Phrases: cryptography, key manage- rors). By using a (k, n) threshold scheme with n = 2k- 1 ment, interpolation we get a very robust key management scheme: We can CR Categories: 5:39, 5.6 recover the original key even when [n/2J = k- 1 of the n pieces are destroyed, but our opponents cannot reconstruct the key even when security breaches expose [n/21 = k- 1 of the remaining k pieces. In other applications the tradeoff is not between secrecy and reliability, but between safety and conve- nience of use. Consider, for example, a company that digitally signs all its checks (see RSA [5]). If each ex- ecutive is given a copy of the company's secret signature key, the system is convenient but easy to misuse. If the 1. Introduction cooperation of all the company's executives is necessary in order to sign each check, the system is safe but in- In [4], Liu considers the following problem: convenient. The standard solution requires at least three Eleven scientists are working on a secret project. They wish to lock signatures per check, and it is easy to implement with a up the documents in a cabinet so that the cabinet can be opened if (3, n) threshold scheme. Each executive is given a small and only if six or more of the scientists are present. What is the magnetic card with one Di piece, and the company's smallest number of locks needed? What is the smallest number of keys to the locks each scientist must carry? signature generating device accepts any three of them in order to generate (and later destroy) a temporary copy of It is not hard to show that the minimal solution uses 462 the actual signature key D. The device does not contain locks and 252 keys per scientist. These numbers are any secret information and thus it need not be protected clearly impractical, and they become exponentially against inspection. An unfaithful executive must have at worse when the number of scientists increases. least two accomplices in order to forge the company's In this paper we generalize the problem to one in signature in this scheme. which the secret is some data D (e.g., the safe combina- Threshold schemes are ideally suited to applications in Permission to copy without fee all or part of this material is granted which a group of mutually suspicious individuals with provided that the copies are not made or distributed for direct commer- cial advantage, the ACM copyright notice and the title of the publica- conflicting interests must cooperate. Ideally we would tion and its date appear, and notice is given that copying is by permis- like the cooperation to be based on mutual consent, but sion of the Association for Computing Machinery. To copy otherwise, the veto power this mechanism gives to each member can or to republish, requires a fee and/or specific permission. Author's present address: A. Shamir, Laboratory for Computer paralyze the activities of the group. By properly choos- Science, Massachusetts Institute of Technology, Cambridge, MA ing the k and n parameters we can give any sufficiently 02139. large majority the authority to take some action while This research was supported by the Office of Naval Research under contract no. N00014-76-C-0366. giving any sufficiently large minority the power to block @1979 ACM 0001-0782/79/1100-0612 $00.75. it.

612 Communications November 1979 of Volume 22 the ACM Number 11 2. A Simple (k, n) Threshold Scheme the company) without affecting the other D i pieces. (A piece is deleted only when a leaving executive Our scheme is based on polynomial' interpolation: makes it completely inaccessible, even to himself.) given k points in the 2-dimensional plane (x,, y,) ..... (3) It is easy to change the D i pieces without changing (xk, Yk). with distinct xi's , there is one and only one the original data D--all we need is a new polynomial polynomial q(x) of degree k - 1 such that q(x) =yi for all q(x) with the same free term. A frequent change of i. Without loss of generality, we can assume that the data this type can greatly enhance security since the pieces D is (or can be made) a number. To divide it into pieces exposed by security breaches cannot be accumulated D~, we pick a random k-1 degree polynomial unless all of them are values of the same edition of q(x)=ao+alx+ ... ak_ixk-~ in which ao=D , and the q(x) polynomial. evaluate: (4) By using tuples of polynomial values as Di pieces, we can get a hierarchical scheme in which the number of D~ = q(1) ..... D i = q(i) ..... D n = q(n). pieces needed to determine D depends on their im- Given any subset of k of these D~ values (together with portance. For example, if we give the company's their identifying indices), we can find the coefficients of president three values of q(x), each vice-president q(x) by interpolation, and then evaluate D=q(O). two values of q(x), and each executive one value of Knowledge of just k- 1 of these values, on the other q(x), then a (3, n) threshold scheme enables checks to hand, does not suffice in order to calculate D. be signed either by any three executives, or by any To make this claim more precise, we use modular two executives one of whom is a vice-president, or by arithmetic instead of real arithmetic. The set of integers the president alone. modulo a prime number p forms a field in which inter- A different (and somewhat less efficient) threshold polation is possible. Given an integer valued data D, we scheme was recently developed by G.R. Blakley [2]. pick a prime p which is bigger than both D and n. The coefficients a~ ..... ak_~ in q(x) are randomly chosen Received April 1979; revised September 1979 from a uniform distribution over the integers in [0, p), and the values D~ ..... Dn are computed modulo p. Let us now assume that k-1 of these n pieces are References revealed to an opponent. For each candidate value D' in 1. Aho, A., Hopcroft, J., and Ullman, J. The Design and Analysis [0, p) he can construct one and only one polynomial of Computer AIgorithms. Addison-Wesley, Reading, Mass., 1974. q '(x) of degree k- 1 such that q '(0) =D' and q '(0 =D~ 2. Blakley, G.R. Safeguarding cryptographic keys. Proc. AFIPS 1979 NCC, Vol. 48, Arlington, Va., June 1979, pp. 313-317. for the k- 1 given arguments. By construction, these p 3. Knuth, D. The Art of Computer Programming, Vol. 2: possible polynomials are equally likely, and thus there is SeminumericalAlgorithms. Addison-Wesley, Reading, Mass., 1969. abolutely nothing the opponent can deduce about the 4. Liu, C.L. Introduction to Combinatorial Mathematics. McGraw- Hill, New York, 1968. real value of D. 5. Rivest, R., Shamir, A., and Adleman, L. A method for obtaining Efficient O(n log 2 n) algorithms for polynomial evalu- digital signatures and public-key . Comm. A CM 21, 2 ation and interpolation are discussed in [1] and [3], but (Feb. 1978), 120-126. even the straightforward quadratic algorithms are fast enough for practical key management schemes. If the number D is long, it is advisable to break it into shorter blocks of bits (which are handled separately) in order to avoid multiprecision arithmetic operations. The blocks cannot be arbitrarily short, since the smallest usable value of p is n + 1 (there must be at least n + 1 distinct arguments in [0, p) to evaluate q(x) at). However, this is not a severe limitation since sixteen bit modulus (which can be handled by a cheap sixteen bit arithmetic unit) suffices for applications with up to 64,000 D~ pieces. Some of the useful properties of this (k, n) threshold scheme (when compared to the mechanical locks and keys solutions) are: (1) The size of each piece does not exceed the size of the original data. (2) When k is kept fixed, D~ pieces can be dynamically added or deleted (e.g., when executives join or leave

LThe polynomials can be replaced by any other collection of func- tions which are easy to evaluate and to interpolate.

613 Communications November 1979 of Volume 22 the ACM Number 11 International Journal for Research in Engineering Application & Management (IJREAM) ISSN : 2454-9150 Vol-05, Issue-12, Mar 2020 Army Data Encode Using Visual Cryptography

1M.V.R. NIKHIL, 2SHIV SHANKAR SINGH, 3B. NIKHIL, 4K. SAI SANKAR, 5D. SAI GANESH PATNAIK, 6G. JAGADISH 1,2,3,4,5 Student, 6Asst. Professor, Dept. of CSE, Anil Neerukonda Institute of Technology and Sciences, Visakhapatnam, Andhra Pradesh, India. [email protected], [email protected], [email protected],[email protected], [email protected], [email protected]

Abstract: In any army a decision is not directly taken by just one commander or leader but rather that same decision is taken only after discussing about that issue and a majority agrees upon it. This had become the base idea of our paper. In this paper, the idea was to secretly transmit a secret image which can possible be any kind of important map or as such to the main people in the army and the original image can be formed only when the required number of people agree to that plan. This is done by the concept called “Visual Cryptography”. Visual Cryptography deals with images. Visual cryptography is a technique which allows visual information such as images ,videos etc. to be encrypted in such a way that the decrypted information appears as a visual image .In this paper we implement visual cryptography on black and white images and colour images(RGB) using “(k , n) secret image sharing algorithm” .This scheme is perfectly secure and very easy to implement. We extend this algorithm in such a way that the secret image is divided into n shares and each share is sent to n different officers and only when at least k officers (k<=n) agree to see the secret and when they combine their individual share, the secret is revealed.

Keywords: bitwise OR, cryptography, decryption, encryption, k out of n shares, (k, n) secret sharing algorithm, RSA, shares, visual cryptography.

I. INTRODUCTION is visually not recoverable if seen individually. Now, each of these „n‟ participants is handed over a share. These share Image Processing is a process of working with images and when stacked over one another would reveal the hidden extracting useful information out of it. Visual Cryptography image. Hence, each of the participants would hold the is one variant of Image Processing where we hide the secret secret but won‟t be able to decode it unless k people come image so that it is not visible as it has to be but as a by and gives their individual share. [1] Naor and Shamir different image. (1994) introduced this cryptographic paradigm for black Visual cryptography is the method of hiding images or and white images. The analysis was carried on a k out of n documents by shadowing the original image into specific scheme, where n is the number of shares created and k is shares which are visually not recoverable. A secret is the minimum number of shares that needs are to be stacked something which is kept from the knowledge of any but the to recover the hidden image. That is if fewer than k shares initiated or privileged. Secret sharing denies a method by are stacked together, the image would still remain unclear. which a secret can be distributed between a group of Within a secret sharing scheme, [2],[3],[10] the secret is participants, whereby each participant is allocated a piece divided into a number of shares and distributed among n of the secret. This piece of the secret is known as a share. persons. When any k or more of these persons (where k ≤ The secret image can only be reconstructed when a n) bring their shares together, the secret can be recovered. sufficient number of shares are combined together. While However, if k - 1 persons attempt to reconstruct the secret, these shares are separated, no information about the secret they will fail. Due to this threshold scheme, we typically can be accessed. That is, the shares are completely useless refer to such a secret sharing system as a (k, n)-threshold while they are separated. These shares when superimposed scheme or k-out-of-n secret sharing. on one another would give away the concealed image. Here, we are going to use the scheme of [3],[10] (k, n) II. LITERATURE SURVEY secret sharing algorithm. This visual cryptographic scheme The basic idea of secret sharing was introduced by consists of „n‟ participants. For the image that has to be [1]Shamir in the year 1994 in his paper “How to Share a recovered, we create „n‟ shares of that secret image which Secret?” where a data D is divided into „n‟ shares/pieces in

213 | IJREAMV05I1260044 DOI : 10.35291/2454-9150.2020.0193 © 2020, IJREAM All Rights Reserved. International Journal for Research in Engineering Application & Management (IJREAM) ISSN : 2454-9150 Vol-05, Issue-12, Mar 2020 such a way that „D‟ can be easily reconstructed from any of Now with this public key, we encrypt all the the „k‟ out of those „n‟ shares/pieces, but the knowledge of pixel values using RSA. at most „k-1‟ pieces cannot reconstruct „D‟. This was 3. Then we split this encrypted image into „n‟ shares implemented by the concept of [6] „Interpolation‟. This idea using [3] (k, n) secret sharing encryption was further developed into [3],[10]K-N Secret Sharing algorithm. algorithm by using a Random Number where in each pixel 4. Then we send each share to each individual person value is being put in any of the „n-k+1 via mails. shares‟(reconstruction factor) out of the „n‟ shares so that a 5. Now, at least „k‟ of „n‟ shares are selected for particular pixel value is definitely found in at least one of merging. the „k‟ shares that are being selected. We also made use of 6. Once the shares are selected, then we overlap and the paper [2] “A Novel Approach on Secure Data Transfer combine these shares using [3] (k, n) secret for General Transactions using Secret Sharing Scheme”. In sharing decryption algorithm. addition to the above-mentioned algorithm, we introduced a 7. Once we got the merged image, then it is time to cryptographic technique to encrypt the secret image and carefully decrypt the merged image. then divide it into „n‟ shares. Later after combining „k‟ 7.1 The decryption starts by decrypting using shares we then need to decrypt the reconstructed image to RSA. The private key that we generated get back the secret image. Here, in this paper we used a earlier is used for RSA decryption. simple symmetric cryptographic algorithm (Caesar Cipher) 7.2 Next, we make use of the key (that we earlier along with a strong asymmetric cryptographic algorithm used for Caesar Cipher encryption) for (RSA) to provide more security. decrypting using Caesar Cipher. III. RELATED WORK This order must match with the reverse order in which All this had been started by [1] Naor and Shamir where encryption is done. If first encryption is Caesar Cipher, in they proposed the idea of k out of n secret sharing decryption using Caesar Cipher has to be done last. algorithm. This model assumes that the secret message is a 8. We will have the final image. collection of black and white pixels and each pixel is Finally, after all these steps we will be able to get the handled separately. Each original pixel can appear in „n‟ original secret image. modified versions called shares. Each pixel in original These are the modules that are being proposed: image is represented by a collection both while and black subpixels, which are printed close to each other on 4.1 Encryption transparencies. This model only works for black and white Encryption is that process where the data is transformed images. Now when a min of „k‟ shares is brought together into an incomprehensible data that is not in its original and stacked one above the other, it gives out the original or format. Encryption is necessary to provide more security to secret image. [3],[4],[10] Later, this idea had been the secret that is being transmitted so that even the shares improved and made simple by using a random number are taken by the intruders, they cannot form the secret back generator. A reconstruction factor is first calculated(n-k+1). to its original form. In this paper, we make use of 2 Now each pixel of the original image is put in (n-k+1) encryption algorithms: first one is a simple and easy shares. This is done for a surety that no pixel of the original symmetric encryption algorithm Caesar Cipher where in image gets missed when we select k shares out of the n every value in each pixel is added with a fixed value(key) shares. Human visual system acts as an OR function. So, and then mod with 256 because every value in a pixel is in having that pixel in at least one of the k shares is enough to the range of 0-255, the next encryption used is a stronger have that pixel in the output. This algorithm works for algorithm RSA which makes use of two pairs of black and white as well as RGB images. keys(public and private). Two encryption algorithms are IV. METHODOLOGY used to make the security much stronger. Time Complexity for Encryption: We are proposing a method that is quite easy and simple to implement. These are the steps of our proposed method. 1) Caesar Cipher Encryption: O(row*column*3) 2) RSA Encryption: O(row*column*3*log(e)) 1. An image that is to be secretly transmitted should be selected. 4.2 Division into „n‟ Shares (n- share generation) 2. This selected image will then be encrypted, The encrypted image is used to perform share generation 2.1 First by using Caesar cipher where in we where the shares of the image is generated using make use of a key and compute a value. Then [3],[4],[10] (k-n) secret sharing algorithm. This algorithm we add this value to all the pixels and mod it as name suggests makes use of n and k values to generate by 256. the shares of the image. In this algorithm a number of 2.2 Then we use RSA encryption where in we matrices equal to „n‟ are created. Now each RGB value in compute a pair of public and private keys. each pixel is placed in any random (n-k +1) number of

214 | IJREAMV05I1260044 DOI : 10.35291/2454-9150.2020.0193 © 2020, IJREAM All Rights Reserved. International Journal for Research in Engineering Application & Management (IJREAM) ISSN : 2454-9150 Vol-05, Issue-12, Mar 2020 matrices [5],[9]. As a result, each matrix does not hold Time Complexity for Division into „n‟ shares: information about all RGB values of pixels and at the same 1) Division into N-Shares: O(row*column*(N-K+1)) time holds enough information to be a share. After all the RGB values are placed now shares are generated based on these matrices. 4.3 Generate and Send e-mails Emails are sent to user‟s emails provided by admin. Here each user would be an army officer who are required to make a decision. The number of emails is equal to number of shares created at the first place. Now, each user will get a share of the secret image.

(a) (b)

Figure 1: System Architecture: a: Encryption and Dividing into „n‟ shares. b: Merging „k‟ shares and Decryption.

4.4 Overlapping k-shares The image reconstructed from shares is decrypted in this module. The reconstructed image is first decrypted using To reconstruct the image from n shares, at least k shares of RSA algorithm. Now the resultant is then decrypted with a those n shares are definitely required. Even though the key using Caesar Cipher. These keys must be same or knowledge of k-1 shares cannot form the original image. related to the ones that are used during encryption. Wrong Now if at least k out of n users accept to contribute their key won‟t give us the original image back and secret won‟t shares, then the image can be reconstructed. Image is be revealed properly. constructed from these shares based on OR operation so that every non-zero pixel is considered and used for image Time Complexity for Decryption: construction. As a result, the image is ready for decryption. 1) Caesar Cipher Decryption: O(row*column*3) Time Complexity for Merging „k‟ shares: 2) RSA Decryption: O(row*column*3*log(d)) 1) Overlapping K-Shares: O(K*row*column*3) 4.5 Decryption

215 | IJREAMV05I1260044 DOI : 10.35291/2454-9150.2020.0193 © 2020, IJREAM All Rights Reserved. International Journal for Research in Engineering Application & Management (IJREAM) ISSN : 2454-9150 Vol-05, Issue-12, Mar 2020

V. EXPERIMENTAL RESULTS File Name Resolution Time taken for Time taken for (w*h) dividing Image combining „k‟ Jung-San Lee et.al suggested security, element into „n‟ shares (in shares to form the enlargement, accuracy and procedure quality as a sec) (n=5) Image (in sec) (k=4) performance measure [7]. Security is glad if every share anits.png 200*200 2.3271 0.3847 reveals no info of the initial image and also the original image can't be reconstructed if their square measure fewer download.jpg 225*225 2.7729 0.4426 than k shares collected. Accuracy is taken into account to be the standard of the reconstructed secret image and Flower.jpg 159*119 1.8608 0.1910 evaluated by peak signal-to-noise (PSNR) live. Procedure quality considerations the full variety of operators needed god.png 450*450 6.3979 1.9212 each to get the set of n shares and to reconstruct the initial secret image. human.jpg 208*243 2.6610 0.4559 File Name Resolution Encryption Time Decryption Time (w*h) (in sec) (in sec) map.jpg 300*168 2.6496 0.4583 anits.png 200*200 0.2362 0.3569 mona.png 256*256 2.9356 0.6124 download.jpg 225*225 0.2951 0.4969 tulip.png 173*292 2.6486 0.4697

Flower.jpg 159*119 0.1234 0.1837 Table-3: Time taken for Dividing an Image into „n‟ shares and Combining „k‟ shares to form an Image for images with different god.png 450*450 1.1775 2.1045 resolutions (n=5.k=4).

human.jpg 208*243 0.2957 0.4895

map.jpg 300*168 0.3117 0.4938

mona.png 256*256 0.4669 0.6476

tulip.png 173*292 0.2989 0.4882

Table-1: RSA Encryption and Decryption times for images with Figure 2: Input Image different resolutions.

File Name Resolution Encryption Time Decryption Time (w*h) (in sec) (in sec)

anits.png 200*200 0.1333 0.0980 download.jpg 225*225 0.1310 0.1270

Flower.jpg 159*119 0.0474 0.0677

god.png 450*450 0.6036 0.5164

human.jpg 208*243 0.1475 0.1214

map.jpg 300*168 0.1162 0.1286

mona.png 256*256 0.1364 0.1672

tulip.png 173*292 0.1157 0.1402

Table-2: Caesar Cipher Encryption and Decryption times for images with different resolutions.

Figure 3: Shares(n=5,k=3)

216 | IJREAMV05I1260044 DOI : 10.35291/2454-9150.2020.0193 © 2020, IJREAM All Rights Reserved. International Journal for Research in Engineering Application & Management (IJREAM) ISSN : 2454-9150 Vol-05, Issue-12, Mar 2020

get back the secret image and maintain all the files related to that image. It can be further extended in such a way that encryption, division into „n‟ shares and mailing those shares be done at one end taken care by one admin and combining „k‟ shares and decryption be done at another end taken care by another admin. This makes this algorithm more feasible and robust to use and work with. Also, with the changing technologies, newer and stronger encryption algorithms can replace the ones that are used in this proposed algorithm. Figure 4: Output Image (Combining at least 4 shares) This same idea can be used in other fields as well like in Peak Signal to Noise Ratio (PSNR) is the ratio between the providing authentication in Photography Contests, Online maximum possible power of an image to that of the power Voting Systems using Visual Cryptography, in Copyright of corrupting noise that affects the quality of its authentication etc. representation. ( ) REFERENCES ( ) [1] Adi Shamir “Communications of the ACM: How to Share a where, L in the maximum intensity level. Secret” Volume 22, Issue 11 Nov. 1979. Mean Squared Error (MSE) is defined as follows, [2] J. Sharmila, Jagadish Gurrala “A Novel Approach on Secure Data Transfer for General Transactions using Secret Sharing

∑ ∑( ( ) ( )) Scheme” International Journal of Computer Applications (0975 – 8887) Volume 172 – No.8, August 2017. where, O is the original image and D is the resultant image. [3] Shyamalendu Kandar, Arnab Maiti “K-N SECRET SHARING VISUAL CRYPTOGRAPHY SCHEME FOR The image that is being recovered (by using the above COLOR IMAGE USING RANDOM NUMBER” International method) after merging properly and decrypting properly is Journal of Engineering Science and Technology (IJEST). same as that of the original image and it is noise free. If at [4] Moni Naor, Adi Shamir “Visual Cryptography” (The all, something is not done properly there will be noise and preliminary version of this paper appeared in Eurocrypt 94). value of PSNR is computed by using the above formulae. If MSE is zero, then there is no noise in the original image. [5] Jagadish, et al., “A Secure Framework for Communicating Multimedia Data in Cover Images using Hybrid VI. CONCLUSION AND FUTURE Algorithms in Wireless Local Area Network”, published Scopus WORKS journal in International Journal of Innovative Technology and Exploring Engineering (IJITEE), ISSN: 2278-3075, Volume-9 Sharing data secretly, especially in the domain of army is Issue-2S3, December 2019. very important. That data that is being transmitted is very sensitive. So, it is very important to transmit data by [6] A. Kalai Selvi, Dr. M. Mohamed Sathik, “Polynomial Based Secret Sharing Scheme for Image Encryption Based on providing security to it. This idea not only makes it difficult Mathematical Theorem” Volume 2, No. 1, Jan-Feb 2011 for intruders to steal the data but also makes it nearly International Journal of Advanced Research in Computer Science. impossible as we encrypt the data before dividing into shares. Encryption provides extra security for the data in [7] Jagadish, P Sanyasi Naidu, published paper “Scalable Methodology to Hide Audio Data in Cover Image using RGB and addition to that data being divided into shares. Now even if Grey Colour based Key Positioning Image Steganography”, the intruder has required number of shares, he won‟t be able IJRTE, ISSN: 2277-3878, Volume-8 Issue-3, September 2019. to get the original image as it is as he doesn‟t know the values of the key. What makes this algorithm good is that, [8] P. Sanyasi Naidu, Reena Kharat “Secure Authentication in the intruder has to get all the required number of shares at Online Voting System Using Multiple Image Secret Sharing”. the first place and this is tough. What is tougher is that even [9] Jagadish Gurrala, Dr.P. Sanyasi Naidu, “Analysis of Existing if he has the required number of shares, he should have the Text Hiding Algorithms for Image Steganography Using TLNUS key values as well. So, its better if the value of „k‟ to be and AES”, Smart Computing and Informatics, Proceedings on SCI closer to the value of „n‟ and also have a good set of keys 2016, Volume 7, pp © Springer Nature Singapore Pte Ltd. 2018, Systems and Technologies 77, https://doi.org/10.1007/978-981- for encryption. 10-5544-7_1, Dec 2017. This proposed method has a compulsion that there should be only one admin and the each shareholder has to take the [10] Debashmita Poddar “(2, N) VISUAL CRYPTOGRAPHIC SCHEME FOR BLACK AND WHITE PIXELS USING shares from and has to bring back the shares to that only SQUARE MATRICES” INDIAN STATISTICAL INSTITUTE, admin. It is that person who initially takes the image to be Kolkata, July 2016. shared secretly, encrypt the image, divide into „n‟ shares, send mails, combine the accepted shares, decrypt the image,

217 | IJREAMV05I1260044 DOI : 10.35291/2454-9150.2020.0193 © 2020, IJREAM All Rights Reserved.