46
Application of Sudoku Puzzle in Encryption and Decryption A PROJECT REPORT ON APPLICATION OF SUDOKU PUZZLE IN ENCRYPTION AND DECRYPTION SUBMITTED IN PARTIAL FULFILLMENT FOR THE REQUIREMENT OF THE AWARD OF DEGREE Master of Science (Computer Science) Paper Code: (MCS-1005) SUBMITTED BY Misbahul Alom Mazumdar Roll-101611 No.-02220139 UNDER THE ABLE GUIDANCE OF Bishwa Ranjan Roy Assistant Professor, Department of Computer Science Regn. No: 01-110021940 Year: 2011-2012 Assam University, Silchar Silchar-7880011, India

A PROJECT REPORT ON APPLICATION OF SUDOKU PUZZLE IN ...€¦ · Application of Sudoku Puzzle in Encryption and Decryption A PROJECT REPORT ON APPLICATION OF SUDOKU PUZZLE IN ENCRYPTION

  • Upload
    others

  • View
    50

  • Download
    4

Embed Size (px)

Citation preview

Application of Sudoku Puzzle in Encryption and Decryption

A PROJECT REPORT

ON APPLICATION OF SUDOKU PUZZLE IN ENCRYPTION AND

DECRYPTION

SUBMITTED IN PARTIAL FULFILLMENT FOR THE REQUIREMENT OF THE AWARD OF

DEGREE Master of Science (Computer Science)

Paper Code: (MCS-1005)

SUBMITTED BY Misbahul Alom Mazumdar

Roll-101611 No.-02220139

UNDER THE ABLE GUIDANCE OF

Bishwa Ranjan Roy

Assistant Professor,

Department of Computer Science

Regn. No: 01-110021940 Year: 2011-2012 Assam University, Silchar

Silchar-7880011, India

Application of Sudoku Puzzle in Encryption and Decryption

DEPARTMENT OF COMPUTER SCIENCE SCHOOL OF PHYSICAL SCIENCES

ASSAM UNIVERSITY SILCHAR

A CENTRAL UNIVERSITY CONSTITUTED UNDER ACT XIII OF 1989

ASSAM, INDIA, PIN - 788011

Certificate

This is to certify that the project entitled “APPLICATION OF SUDOKU PUZZLE

IN ENCRYPTION AND DECRYPTION” submitted by Misbahul Alom

Mazumdar ( Roll: 101611 No:02220139 Regn no. 01-110021940 of 11-12) in

partial fulfillment of the requirement for the award of degree in Master of Science

(Computer Science) of Assam University, Silchar, is a presentation of bonafide work

carried out by him.

Date: …………………. Bishwa Ranjan Roy

Assistant Professor,

Department of Computer Science,

Assam University, Silchar

Application of Sudoku Puzzle in Encryption and Decryption

DEPARTMENT OF COMPUTER SCIENCE SCHOOL OF PHYSICAL SCIENCES

ASSAM UNIVERSITY SILCHAR

A CENTRAL UNIVERSITY CONSTITUTED UNDER ACT XIII OF 1989

ASSAM, INDIA, PIN - 788011

Certificate

This is to certify that the project entitled “APPLICATION OF SUDOKU PUZZLE

IN ENCRYPTION AND DECRYPTION” submitted by Misbahul Alom

Mazumdar was done under the able guidance of Mr. Bishwa Ranjan Roy, Assistant

Professor, Department of Computer Science, Assam University, Silchar in partial

fulfillment of the requirement for the award of degree in Master of Science

(Computer Science) of Assam University, Silchar, is a presentation of bonafide work

carried out by him.

Date: Dr. Bipul Shyam Purkayastha

Place: HOD, Department of Computer Science,

Assam University, Silchar

Application of Sudoku Puzzle in Encryption and Decryption

DECLARATION

I, MISBAHUL ALOM MAZUMDAR do here by declare that the term paper work entitled

“APPLICATION OF SUDOKU PUZZLE IN ENCRYPTION AND DECRYPTION”

has been carried out by me under the guidance of Mr. Bishwa Ranjan Roy, Assistant

Professor, Department Of Computer Science, Assam University, Silchar. Whenever I have

used materials (data, theoretical analysis, figures, and text) from other sources, I have given

due credit to them by citing them in the text of this report and giving their details in the

references.

Date: Misbahul Alom Mazumdar Place: Assam University Roll: 101611 No.-02220139

Regn. No: 01-10021940 of 2011-12 Department Of Computer Science

Application of Sudoku Puzzle in Encryption and Decryption

ACKNOWLEDGEMENT

My sincere gratitude and thanks towards my term paper guide Mr. Bishwa Ranjan Roy, Assistant

Professor, Department of Computer Science, Assam University, Silchar, Assam, India.

It was only with his backing and support that I could complete the report. He provided me

all sorts of help and corrected me if ever seemed to make mistakes. I have no such words to

express my gratitude.

I acknowledge my sincere gratitude to the HOD of Computer Science Department, Assam

University, Silchar. He gave me the permission to do the project work. Without his support

I couldn’t even start the work. So I am grateful to him.

I acknowledge my sincere gratitude to the lecturers, research scholars and the lab technicians

for their valuable guidance and helping attitude even in their very busy schedule.

And at last but not the least, I acknowledge my dearest parents for being such a nice source of

encouragement and moral support that helped me tremendously in this aspect.

I also declare to the best of my knowledge and belief that the Project Work has not been submitted

anywhere else.

Place: Assam University, Silchar MISBAHUL ALOM MAZUMDAR Date: Roll: 101611 No.: 02220139

Department of Computer Science

Application of Sudoku Puzzle in Encryption and Decryption

TABLE OF CONTENTS

Certificates I-II

Declaration III

Acknowledgement IV

Table of figures V

Abstract VI

Page No. Chapter1: Introduction 1

1.1 A brief description of encryption and decryption……………………………...3

1.2 A description of Sudoku……………………………………….…………….....4

1.3 Problem Statement………………………….………………………………….5

1.4 Application Of Sudoku................................................................................................6

1.5 Motivation…………………………………………………………………………………….6

1.6 Objective………………………………………………………………………………………6

Chapter 2: Literature Survey

2.1 Sudoku rules and solving technique…………………………………………………8

2.2 Previous Research……………………………………………………………………...10

2.3Encryption and Decryption existing works…………………………………………..11

2.4 Related works ……………………………………………………………..……………12

Chapter 3: Examined Algorithms 13

3.1 Pencil-and-Paper Algorithm………………………………………………………….13

3.2 Brute-force Algorithm………………………………………………………………….17

3.3 Time complexity………………………………………………………………………...20

Chapter 4: Proposed Technique 22

4.1 Proposed Algorithm……………………………………………………………………22

4.2 Key Analysis…………………………………………………………………………….23

Application of Sudoku Puzzle in Encryption and Decryption

Chapter 5: Implementation 27

Chapter 6: Conclusion And Future Works 30

References 31

Appendices 32

Appendix A User Interface 32

Appendix B Software Package 37

Application of Sudoku Puzzle in Encryption and Decryption

Lists of Figures Page no.

Fig. 1.1: Encryption and Decryption Process 3

Fig. 1.2: An illustration of Symmetric key and public key encryption. 4

Fig 2.1: The original puzzle 8

Fig 2.2: The solved puzzle 8

Fig 3.1: An illustration of unique missing candidate 14

Fig 3.2: A description of the naked single method. In the left figure square 15

4b can hold just one possible number, which is 2 as it is inserted in the

Right figure.

Fig. 3.3: A partially solved Sudoku puzzle 18

Fig.3.4: A partially solved Sudoku puzzle with its lists of possible values 19

Fig. 3.5: The solved puzzle 20

Fig4.1: A is related to 20 other cell 24

Fig4.2: Redundant numbers 25

Fig4.2: Excluding Redundant numbers 25

Fig4.3: Flowchart for the Proposed Algorithm 28

Appendices

GUI Snapshots 32-36

Application of Sudoku Puzzle in Encryption and Decryption

ABSTRACT

With the changing information age, the need for security and privacy is essential. As

the number of user increases the need for security and privacy also increases. The

communication process needs to be more secure and private. So, combination of

encryption and decryption for secure communication is an application which combines

both (i.e., Encryption and decryption) techniques to make the communication more

secure. It is concerned with embedding information in a secure and robust manner.

In this project report, we propose an algorithm using which we can encrypt and

decrypt information using a Sudoku puzzle. Unlike steganography, we will encrypt a

message in a Sudoku matrix using a symmetric key and generate a Sudoku puzzle in such

a way that it results in a unique solution. From this unique solution, a Sudoku puzzle is

generated randomly consisting a minimum of 32-clues in which the message is encrypted.

The partially solved Sudoku puzzle acts as a cipher text. The cipher text is then decrypted

to get the original text by applying the key to it.

Application of Sudoku Puzzle in Encryption and Decryption

CHAPTER 1

1.1 Introduction

With the growth of computer network, security of data has become a major concern and

thus data hiding technique has attracted people around the globe. Data hiding techniques provide

an interesting challenge for digital forensic investigators. Data is the backbone of today’s

communication. To ensure that data is secured and does not go to unintended destination, the

concept of data hiding came up to protect a piece of information. Digital data can be delivered

over computer networks with little errors and often without interference. The Internet provides a

communication method to distribute information to the masses. Therefore, the confidentiality and

data integrity are required to protect against unauthorized access and use. Steganography and

cryptography are two different information hiding techniques, where we transform the message so

as to make it meaning obscure to a malicious people who intercept it.

Steganography relies on hiding message in unsuspected multimedia data and is generally

used in secret communication between acknowledged parties [1]. The technique replaces unused

or insignificant bits of the digital media with the secret data. The concept is to embed the hidden

object into a significantly larger object so that the change is undetectable by the human eye.

All digital file formats can be used for steganography, but the formats those are with a high

degree of redundancy are more suitable. The redundant bits of an object are those bits that can be

altered without the alteration being detected easily. The most popular cover objects used for

steganography are digital images. Digital images often have a large amount of redundant data, and

this is what steganography uses to hide the message. Cryptography merely obscures the integrity

of the information so that it does not make sense to anyone except the creator and the recipient.

Steganography could be considered as the dark cousin of cryptography. Cryptography assures

Application of Sudoku Puzzle in Encryption and Decryption

privacy whereas Steganography assures secrecy. Steganography and cryptography are both used

to ensure data confidentiality. However, steganography differs from cryptography in the sense that

the cryptography focuses on keeping the contents of a message secret, steganography focuses on

keeping the existence of a message secret [2]. Thus, with cryptography anybody can see that both

parties are communicating in secret. Steganography hides the existence of a secret message in such

a way that nobody can see that both parties are communicating in secret.

The basics of embedding data rely on three different facts i.e. capacity, security, and

robustness. Capacity means the media on which the data is to be hidden should hold the data, so

that the complexity of the medium should not be disturbed. Security means the embedding

algorithm is said to be secure if the embedded information cannot be removed beyond reliable

detection by targeted attacks. Finally, robustness means the amount of manipulation a cover image

(original image) can handle without drawing any attention that a change has taken place.

Steganography and cryptography have to guarantee any of the requirements.

Steganography and Cryptography are parallel data security techniques and the techniques can be

implemented side by side, in fact stenographic system can implement cryptographic data security.

With cryptography we can protect the message but not hide its existence.

Steganography pay attention to the degree of invisibility while cryptography pays attention to the

security of the message. Once the presence of hidden information is revealed or even suspected,

the purpose of steganography is partly defeated. The strength of steganography can thus be

increased by combining it with cryptography [1].

Application of Sudoku Puzzle in Encryption and Decryption

1.2 A brief description of Encryption and Decryption

Encryption is the process of coding information which could either be a file or mail

message in into cipher text a form unreadable without a decoding key in order to prevent anyone

except the intended recipient from reading that data. Decryption is the reverse process of

converting encoded data to its un-encoded form, plaintext[2].

Fig. 1.1: Encryption and Decryption Process

When a user encodes a file, another user cannot decode and read the file without the

decryption key. So, a key is used to decode a cipher text to get the original plain text. An encryption

algorithm takes the original message and a key, and alters the original message based on the key

to a cipher text and creates a new encrypted message. Likewise, a decryption algorithm takes an

encrypted message and restores it to its original form using one or more keys[2].

There are two primary approaches to encryption:

a) Symmetric key encryption

b) Public key encryption

Symmetric encryption is the most common type of encryption and uses the same key for

encoding and decoding the data. This key is known as a session key.

Public-key encryption uses two different keys, a public key and a private key. One key

encodes the message and the other decodes it. The public key is widely distributed while the

private key is secret.

Application of Sudoku Puzzle in Encryption and Decryption

Fig. 1.2: An illustration of Symmetric key and public key encryption.

1.3 A description of Sudoku

Sudoku is a game made up of 81 cells (grid) organized into 9 rows, 9 columns, and 9

boxes (mini-grid). A puzzle will start with 17 or more cells already filled in. The challenge is to

fill in the rest. To solve a puzzle, the user places 1 through 9 in each row, each column, and each

mini-grid such that no number repeats itself in that particular row, column or mini-grid [3].

Sudoku is a challenging numeric puzzle that trains our logical mind!! There’s no math

involved in it-we just need to solve the numeric puzzle with reasoning and logic. It is a game that

one finds himself addicted into. Solving a Sudoku puzzle requires no math, not even arithmetic.

Even so, the game poses a number of Intriguing mathematical problems.

Sudoku presents mathematicians and computer scientists with a host of challenging

issues. Sudoku puzzles, and their variants, have become extremely popular in the last decade, and

can now be found daily in most major newspapers. In addition to the countless books of Sudoku

puzzles, there are many guides to Sudoku strategy and logic. Unlike the three-dimensional Rubik’s

cube, a Sudoku puzzle is a flat, square grid. Typically it contains 81 cells (nine rows and nine

columns) and is divided into nine smaller squares containing nine cells each; call them sub grids

or regions. The game begins with numbers already printed in some cells. The player must fill in

the empty cells with the numbers 1 to 9 that each column, row and region contains that number

exactly once. Thus repetition of a number is strictly abandoned. Each puzzle has one unique

solution [4].

Application of Sudoku Puzzle in Encryption and Decryption

An n²×n² Sudoku grid (consisting of nxn blocks) is an NP complete problem. NP-

complete problems are a subset of the class NP (Non-Deterministic Polynomial). A Non-

deterministic algorithm is able to find a correct solution, but it is not always guaranteed. The

solution is found by making a series of guesses, and the algorithm will only arrive at a correct

solution, if the right guesses are made along the way. A problem is called NP, if its solution can

be found and verified by a non-deterministic algorithm in polynomial time.

1.4 Problem Statement

We need a Sudoku Solver to use encryption and decryption over Sudoku puzzle. Valid

Sudoku grid only have a single solution. A valid grid for which no given can be removed unless

an invalid grid is obtained is called irreducible or minimal. For classical Sudoku (9 × 9), the

smallest known number of givens that leads to a valid grid is 17. Nobody knows if a smaller

number is possible. Generally, the opposite is conjectured.

Sudoku is a logic-based, combinatorial puzzle. The objective is to fill a 9×9 grid with

digits so that each column, each row, and each of the nine 3×3 sub-grids that compose the grid

(also called "boxes", "blocks", "regions", or "sub-squares") contains all of the digits from 1 to

9.The puzzle setter provides a partially completed grid, which typically has a unique solution.

In this project, the problem is to encrypt a message M to the Sudoku puzzle using a

symmetric key. The encryption should be done in such a way that no two number should be in the

same row, column or each mini-grid. And the message M should be successfully decrypted.

Application of Sudoku Puzzle in Encryption and Decryption

1.5 Applications of Sudoku

There are various applications of Sudoku. Some of them are stated below:

1. Sudoku solving algorithms can be used in artificial intelligence.

2. Sudoku puzzles have been translated into coloring problems that links the game to class of

important mathematical problems.

3. The Sudoku puzzle is used in data hiding techniques like Steganography. The Sudoku is

used like a key to hide data behind images.

1.6 Motivation:

Sudoku is an NP-Complete problem which cannot be solved in polynomial time algorithm.

Also Sudoku has many application in the field of Security. As it is an NP-Complete problem, it

cannot be solved in polynomial time algorithm but this does not means that this type of problem

cannot be solved. It will be of interest to use this puzzle in encryption and decryption as this type

of problem cannot be solved by polynomial time algorithm. Also, the complexity for this type

puzzle is O(nn) which is exponential. Due to this it will be interesting to use in Encryption as it

can provide better Security.

1.7 Objective:

The objective of the project is to encrypt and decrypt a message using a Sudoku puzzle. This

can be done with the unique solution of Sudoku. So the objective is also to get the unique solution

of a Sudoku puzzle.

Application of Sudoku Puzzle in Encryption and Decryption

CHAPTER 2

Literature Survey

Sudoku is a game made up of 81 cells (grid) organized into 9 rows, 9 columns, and

9 boxes (mini-grid). A puzzle will start with 17 or more cells already filled in. The

challenge is to fill in the rest. To solve a puzzle, the user places 1 through 9 in each row,

each column, and each mini-grid such that no number repeats itself in that particular row,

column or mini-grid [8]. 2.1 Definitions

Table 1 depicts the meaning of different terms used in this term-paper is given in is this table:

TERM DEFINITION Cell A single square in the puzzle

Box A group of 3X3 cells

Grid A group of 3X3 boxes

Column A column of 9 cells

Row A row of 9 cells

Given Value A value(between 1-9) that was already assigned to cell at the start

of a game, which cannot be changed

Valid input

A value that can be inserted into a cell without violating the rule of

the game at time when the value is inserted. Does not mean the

value inserted is the correct value for the game

Possible values List of valid inputs for a cell

Table 1: Lists of Definitions

Application of Sudoku Puzzle in Encryption and Decryption

2.1 Sudoku Rules and solving Technique-

To solve the Sudoku, we must fill each of the small blank squares called 'cells' with the

correct numbers 1 through 9. To do this, we follow three simple rules:

1) Every column must contain all the numbers 1 through 9 in any order.

2) Every row must contain all the numbers 1 through 9 in any order.

3) Every 3x3 box must contain all the numbers 1 through 9 in any order.

Since each column, row, and box can only contain 9 numbers and must contain all numbers 1

through 9, no number can be repeated within a column, row, or box. These simple rules provide

the basis for solving the Sudoku.

Fig 2.1: The original puzzle Fig 2.2: The solved puzzle

2.2.1The difficulty level of Sudoku Puzzles

The difficulty level of Sudoku puzzles depends on how the given numbers are placed in the

Sudoku board and also how many numbers (clues) are given. Generally, the most significant

aspect of difficulty ratings of Sudoku puzzles is that which techniques are required to solve the

puzzles. In other words, it is important where the numbers are placed logically .Generally, a

Sudoku puzzle needs at least 17-clues to solvable. It means that solving a Sudoku puzzles with

17-Clues is more difficult than a 30-clues.More given numbers, the easier and quicker the solution

is. This statement may not always truth that if the number of clues becomes more the run-time of

solving the puzzle would be shorter. For instance, when solving the puzzle with 28 clues the

Application of Sudoku Puzzle in Encryption and Decryption

solving time is increases rapidly. The reason is that puzzle needs more techniques to solve it or

the algorithm needed to iterate as long as the solution is found [5].

2.2.1(a) Description of levels

Easy

Sudoku generally have 36 - 49 givens(out of the total of 81 numbers in the

Answer).

It has more than one given in every box.

This level each digit from 1–9 appears as a given at least 3 times.

It is very quick to solve, less than 10 minutes on average, and no guesses are

Required.

Medium

Sudoku have around 32–35 givens.

It has a couple of boxes with only one given.

This level has some digits may only appear twice as a given, the rest will appear at least 3

times each.

It take a bit longer to solve, somewhere between 10–20 minutes. No guesses are required.

Hard

Sudoku have around 28–31 givens.

It may have a couple of boxes with only one given

This level has three or four digits may only appear 2 times as givens, and one digit may

only appear once.

Very Hard

Sudoku may have several boxes with less than 22 - 27 givens.

It may have several boxes with no givens at all

This level has most digits appear only 2 or 3 times, as well as several single

Occurrences.

It can take over an hour to solve, and require trial and error.

In 2005 Felgenhauer & Jarvis calculated that there are 6.67 x 1021 valid Sudoku grids possible,

meaning that there are 985 billion unique puzzles per person on the planet.1 Even though this

Application of Sudoku Puzzle in Encryption and Decryption

number includes grids generated by permutations such as reflection and rotation, it is unlikely we

will run out of puzzles any time soon. In this section we will investigate the history of Sudoku and

its rise to current popularity

2.2 Previous Research on Sudoku puzzle

We have noticed that there is a large volume of published studies describing Sudoku

problems. Furthermore, several research have been made to solve Sudoku problems in a more

efficient way. It has conclusively been shown that solving the puzzle, by using different

algorithms, is definitely possible but most developers seek for optimizations techniques such as

genetic algorithms, simulated annealing, etc. Different authors have made relative works already.

Nelishia Pillay [9] gives a solution for solving Sudoku by combining human intuition and

optimization. This author has investigated the use of genetic programming to improve a space of

programs combined of the heuristics moves. However, we seek a solution to solve Sudoku puzzle

based on human strategies, which uses techniques such as: naked single method, hidden single

method etc.

J.F. Crook [10] have also discussed about solving Sudoku and presented an algorithm on how to

solve the puzzles of differing difficulty with pencil-and-paper algorithm. This method has not been

implemented and therefore it is hard to discuss how the algorithm performs.

Tom Davis [11] has done a research about “The Mathematics of Sudoku”. Tom has described all

techniques that people usually use to solve the puzzles but his major attempt is to describe these

techniques from mathematical perspective. However, all the strategies he mentions are not

required to solve the puzzle. For instance the easy puzzles can be solved using only one or two

strategies.

Application of Sudoku Puzzle in Encryption and Decryption

2.3 Encryption and Decryption existing works

2.3.1 Symmetric Key Encryption Algorithms

The most widely used symmetric key encryption method is the Data Encryption Standard (DES),

published in 1977 by National Bureau of Standards. DES is still the most widely used symmetric

key approach. It uses a fixed length, 56-bit key and an efficient algorithm to quickly encrypt and

decrypt message.

Another Algorithm for Symmetric key encryption is the International Data Encryption Algorithm

(IDEA) invented by James Massey and Xuejia Lai of ETH Zurich, Switzerland in 1991. IDEA

uses a fixed length, 128-bit key which is larger than DES.

Despite the efficiency of symmetric key encryption, it has a fundamental spot-key management.

Since, the same key is used for both encryption and decryption, it must be kept secure. If an

adversely knows the key, then the message can be decrypted.

2.4. Asymmetric Key Encryption Algorithms

Asymmetric key encryption overcomes the key management problem by using different

encryption and decryption key pairs. Having knowledge of one key, say encryption key, is not

sufficient enough to determine the other key- the decryption key. Therefore, the encryption key

can be made public, provided the decryption key is held only by the party wishing to receive

encrypted message. Anyone can use the public key to encrypt a message but only recipient can

decrypt it.

RSA is widely used Asymmetric algorithm and is named after the initials of its inventors, Ronald

L. Rivest, Adi Shamir, and Leonard M. Adleman [RSA 91]. It depends on the difficulty of

factoring the product of two very large prime numbers. Although used for encrypting whole

messages, RSA is much less efficient than Symmetric key algorithms such as DES.

Application of Sudoku Puzzle in Encryption and Decryption

2.5 Related Works

1. Shailender Gupta et al. [12] have proposed an information hiding scheme for the least

significant bit Steganography along with cryptographic method. In this proposed scheme, the raw

data was encrypted before embedding it into the image. This system makes use of Rivest, Shamir,

Adleman (RSA) algorithm and the Diffie Hellman algorithm to encrypt the secret information. To

provide higher security, the secret value is encrypted and then it was converted to binary form.

Meanwhile, the image pixels were also converted to binary form and then the encrypted secret

information was embedded into the image by an LSB encoder.

2. Akhil Khareet al. [13] have proposed a system that allows user to transfer text messages

securely by hiding them into a digital image file. This system was a combination of both

Steganography and encryption algorithms and provides a strong backbone for its security. This

system also proposed a framework for hiding the large volume of data in images while incurring

minimal perceptual degradation. In this proposed method, Entropy thresholding (ET) and

Selectively Embedding in Coefficients (SEC) were used to decide whether or not to embed the

secret data into the image. This system was mainly used for applications that require high-volume

embedding with robustness.

3. Pasumarthy Saradha et al. [14] have proposed a scheme for improving data hiding capacity

using Sudoku puzzle in color images. The main idea of the scheme was to use a Sudoku puzzle, in

which every value corresponds to a pixel pair (red, blue) of the image mapped with the secret by

replacing a pair of one pixel of two colors. This scheme was proposed to improve the visual quality

of the stego-image and to improve the average hiding capacity of the image to 4 bpp (bits per

pixel). This scheme makes use of 24 bit of any type of image and modifies 16 bit of each pixel.

The Sudoku solution was used as a reference matrix for both embedding and extracting the secret

data into and from the image.

4. Vikas Tyagi et al. [12] have proposed a steganographic method using Least Significant Bit

(LSB) along with a cryptographic algorithm. The symmetric cryptographic algorithm was used for

encryption of the secret message. This algorithm uses random size of the key. After converting the

information into secret code or encrypted form it was patched into the image. For patching the

secret data, the least significant bit of the image was used.

Application of Sudoku Puzzle in Encryption and Decryption

CHAPTER 3

Examined Algorithms

3.1 Pencil-and-paper algorithm In this work, we implement a solution based on some strategies used by humans when

solving the puzzle, therefore, it is called pencil-and-paper algorithm.

The paper-and-pencil algorithm contains human strategies. These strategies have been

examined below in more details. These techniques are almost easy to understand by human

players, but it might be hard to search in the puzzle, since there are several things to look

for at the same time. As there are puzzles with different types of difficulty, the easy and

medium puzzles can be solved using some simple techniques such as unique missing

method, naked singles. However to solve difficult problems we may examine other

techniques as well (locked candidates, naked and hidden pairs, triplets etc.) [5].

The methods that are used in this algorithm are the following:

Unique missing candidate

Naked single method

Backtracking

Application of Sudoku Puzzle in Encryption and Decryption

3.1.1 Unique missing candidate

This method is useful when there is just only one empty square in a row, column or

box. The digit that is missing can be placed in that empty square. A similar definition is

that if eight of nine empty squares are filled in any row, column or box, then the digit that

is missing can fill the only empty square. This method can be useful when most of the

squares are filled, especially at the end of a solution. It can also be suitable when solving

easy puzzle and this method is efficient to find solution in this case. In this algorithm, the

method goes through all rows, columns and boxes separately. The method then checks if a

single value has missed in any row, column or box and place the single digit in that specific

square[5].

Fig 3.1: An illustration of unique missing candidate

3.1.2 Naked Singles

The second method that is used in the pencil-and-paper algorithm is the naked single

method. This method checks every empty square in the Sudoku board and finds the square

that can only take one single digits and the missing digit then is assigned to that square.

Note that once the squares are filled by naked single digits other naked singles will appear.

This process is repeated until the method has found all empty squares with the needed

corresponding one single value and complete the board[5].

This method is a useful method when a human player solves the game. However if the

corresponding method is combined with the unique missing candidate method then both

the methods can solve the puzzles both in easy and medium levels quickly and more

efficiently., see Fig.3. 2

Application of Sudoku Puzzle in Encryption and Decryption

Fig 3.2: A description of the naked single method. In the left figure square 4b can hold just one possible

number, which is 2 as it is inserted in the right figure.

As we see in figure 2, it is possible to list all the candidates from 1 to 9 in each unfilled

square, i.e. square 4b can only hold number 2 since it is the only candidate for this position.

The most significant aspect is that when a candidate is found for a certain position then it

can be removed from the list as a possible candidate in the row, column and box [7]. The

reason that it is called the “naked single” method is that this kind of square contains only

one possible candidate.

Pencil-and-Paper algorithm

Pencil-and-paper (puzzle [][]){ puzzle [][]

Solve the puzzle{

For 1 to 9

Naked Single Method (puzzle[][]) check all rows (puzzle[][]) //check if there is

only one candidate that is missing, place that missing digit in

the empty square check all columns

(puzzle[][]) check all boxes (puzzle[][]) }

Application of Sudoku Puzzle in Encryption and Decryption

If the puzzle is solved: print

Otherwise: recursiveBacktracking (puzzle[][]) Print the solved puzzle }

3.1.3 Backtracking (guessing method)

The unique missing method and the naked single method are able to solve all

puzzles with easy and medium level of difficulties. In order to solve puzzles with even

more difficult levels such as hard and evil the backtracking method has been used to

complete the algorithm. A human player solves the puzzle by using simple techniques. If

the puzzle is not solvable by using the techniques the player then tries to fill the rest of

the empty squares by guessing[5].

The backtracking method, which is similar to the human strategy (guessing), is used as a

help method to the pencil-and-paper algorithm. In other words, if the puzzle cannot be

filled when using the unique missing method and the naked single method, the

backtracking method will take the puzzle and fill the rest of empty squares. Generally, the

backtracking method find empty square and assign the lowest valid number in the square

once the content of other squares in the same row, column and box are considered.

However, if none of the numbers from 1 to 9 are valid in a certain square, the algorithm

backtracks to the previous square, which was filled recently.

The above-mentioned methods are an appropriate combination to solve any Sudoku

puzzles. The naked single method can find quickly single candidates to the empty squares

that needed only one single value. Since the puzzle comes to its end solution the unique

missing method can be used to fill rest of the puzzles. Finally, if either method fills the

board the algorithm calls the backtracking method to fill the rest of the board.

Application of Sudoku Puzzle in Encryption and Decryption

Algorithm

recursiveBacktrackning(Puzzle[][]){

Puzzle [][] //global

solvePuzzle(row,col){

if (no more choices): the puzzle is solved!

If (puzzle[row][col]= notEmpty): move to the next square. for 1 to 9:

if(checkRow(row,col,digit) & checkCol(row,col,digit) &

checkBox(row,col,digit){ puzzle[row][col]= digit; move to the next

square

}

if not valid number is found go the previous square that was recently filled

}

Pros- It should be noted that the level one puzzle could be almost completely solved by the

constraint propagation algorithm and required little actual search.

Cons- The search algorithm is expensive and avoiding it entirely is very valuable in those cases

where it is possible.

3.2 Brute Force Algorithm

The second algorithm that is examined in this work is Brute force algorithm.

Usually, the brute force algorithm can be applied to any possible algorithm. For example

when finding password, the algorithm generates any possible password until the right one

is found. In this case the algorithm goes through every empty square and places a valid

digit in that square. If no valid number is found the algorithm comes back to the previous

square and change the value in that square. The process is repeated until the board is filled

with numbers from 1 to 9 [3].

Generally, the brute force algorithm goes through the empty squares, filling in numbers

from the existing choices, or removing failed choices if a “dead-end” is reached. For

example, Brute force solve a puzzle by inserting the digit “1” in the first square. If the digit

Application of Sudoku Puzzle in Encryption and Decryption

is allowed to be there by checking row, column and box then the program go to the next

square, and put the digit “1” in that square. The program discovers that the “1” is not

allowed, then the digit increments by one i.e. it has become 2. When a square is noticed

where none of the digits (1 to 9) is permitted, then the program backtracks and comes back

to the prior square. The value in that square increases by 1. The process is repeated until

the correct digits fill all 81 squares [15]. We consider the partially solved Sudoku puzzle

shown in Figure

Fig. 3.3: A partially solved Sudoku puzzle

Application of Sudoku Puzzle in Encryption and Decryption

Fig.3.4: A partially solved Sudoku puzzle with its lists of possible values

The most natural way to solve the puzzle would be to do some guesswork. We can select

a value for an unsolved cell and apply the earlier techniques to see if that will solve the

puzzle. If that doesn’t solve the puzzle, select a value for the next unsolved cell and repeat

the same process until the puzzle is solved. Now, the question is: which cell do we start

with? Well, quite obviously you should start with the cell with the least number of possible

values. Scanning from left to right, top to bottom, you can see that cell (1,1) is the first

choice. In (1,1) there are two possible values, 5 and 8. You can choose either 5 or 8, but

for simplicity you can always start with the first number. So let’s choose 5 for (1,1) and

then proceed to solve the puzzle using the techniques we have discussed. The puzzle gets

solved, as shown in Figure 2.1.23.

Application of Sudoku Puzzle in Encryption and Decryption

Fig. 3.5: The solved puzzle

The advantage of the brute force algorithm is that the algorithm can guarantee a solution

to any puzzles since it generates all possible answers until the right answer is found if the

puzzles are valid [9]. Additionally, the running time can be unrelated to level of difficulty,

because the algorithm searches for every possible.

Pros- A solution is guaranteed (as long as the puzzle is valid) Solving time is mostly unrelated to

degree of difficulty.

Cons- The algorithm is it may be comparatively slow when compared to computer solution

methods modeled after deductive methods.

3.3 Time complexity

Time complexity of an algorithm describes the time that is needed to run on a

computer and it is commonly expressed using with O notation. One way to estimate time

complexity is to count the number of operations achieved by the algorithm. Since the

performance time can be changed with different inputs of the same size we use the worst-

case time of complexity, denoted as T (n). A recent study by Kovacs showed that the worst-

case complexity is related to the difficulty of the hardest puzzle.

Application of Sudoku Puzzle in Encryption and Decryption

We shall examine the time complexity of Sudoku solver. The input to a Sudoku solver is

a Sudoku board. The standard board is a 9X9 grid and both smaller and larger boards are

used. These types of puzzles with small sizes can be solved quickly and faster by computer,

but only because this is small for a computer. Solving Sudoku is one of NP-complete

problems and it says that Sudoku algorithms do not scale well to larger boards and puzzles,

for example 10000X10000 grids is not feasible. If the size of input to Sudoku solver goes

to infinity the time of complexity will increase exponentially. However, when solving the

puzzles with limited input size such as 9X9 grids it is feasible because they can be solved

in polynomial time [3].

Application of Sudoku Puzzle in Encryption and Decryption

CHAPTER 4

4.1 Proposed Encryption and Decryption Technique Using Sudoku

Cryptography is the science of using mathematics to encrypt and decrypt data.

Cryptography jumble a message so it cannot be understood. Cryptography systems can be broadly

classified into symmetric-key systems that use a single key that both the sender and the receiver

have, and public-key systems that use two keys, a public key known to everyone and a private key

that only the recipient of messages uses .

Encryption is the process of encoding messages or information in such a way that only authorized

parties can read it. Decryption is the reverse process to encryption. Frequently, the same cipher is

used for both encryption and decryption. While encryption creates a cipher text from plaintext,

Decryption creates plaintext from cipher text.

So to apply our proposed technique for encryption and decryption, we need to solve a Sudoku

Solver in which we will encrypt our message using a Symmetric key.

For example, we want to encrypt a password “152813395”. So we will encrypt the password using

a key. Here our key is “Centre cell of each grid” which means that each digit of password is put

in the Centre cell of each 9x9 mini-grid and create a Sudoku puzzle. We will increase the number

of clues to a minimum of 32-clues which will result in a unique solution in which the password is

encrypted. From the resulting unique solution, we will generate a Sudoku puzzle randomly from

the previous resulting unique solution with a minimum of 32-clues. Now the message is encrypted

inside the partially solved Sudoku puzzle. Nobody can know the password until the partially solved

Sudoku puzzle is solved and apply the Symmetric key on it.

To decrypt the password, one should solved the Sudoku puzzle created randomly which

will always result in a unique solution. If somebody fails to get the unique solution then the puzzle

Application of Sudoku Puzzle in Encryption and Decryption

will give wrong encrypted message. After solving the partially solved Sudoku puzzle we will get

a unique solution exactly similar to the first solution. Applying the symmetric key over it we can

decrypt the encrypted message.

Algorithm:

Step 1: Put the message in the blank Sudoku with the help of a symmetric key and generate

a Sudoku puzzle with a minimum of 32-clues.

Step 2: Solve the Sudoku puzzle generated in step 1 which will give a unique solution.

Step 3: Select some clues randomly from the unique solution and create a Sudoku puzzle with a

Minimum of 32-clues in which the message is encrypted.

Step 4: To decrypt the message, solve the Sudoku puzzle generated in step 3.

Step 5: Apply the symmetric key on the solved solution which will give the encrypted message.

As we have seen that, to encrypt a message and to decrypt the encrypted message to get

the original message, we need a unique solution of Sudoku. Until and unless we have a unique

solution, the encrypted message will differ from the decrypted message.

4.2 Key space analysis

A good encryption scheme should be sensitive to the secret keys, and the key space should

be large enough to make brute force attacks infeasible. Theoretically, the guess and check Sudoku

matrix generator is able to generate all possible Sudoku matrices. In order to explain how large

this number can be, we use the number of full arrangement as a reference. Since a mapping of an

arrangement of N digits of a given Sudoku matrix is still a valid Sudoku matrix, the total number

of all possible Sudoku matrices of size N is much larger than the all possible arrangements of N,

i.e. N!. For example, when N = 9 the total number of all possible Sudoku matrices is

6,670,903,752,021,072,936,960 = 27 2.5 and the total

Number of9! = 218.5. However, just for N = 100, 100! = 2525. Therefore, it is clear to see that this

total number of all possible Sudoku matrices will increase dramatically when N arises and the key

space is sufficient large for preventing any brute force attacks.

Application of Sudoku Puzzle in Encryption and Decryption

16-Clue Puzzle cannot give Unique Solution:

To prove this we will follow the following steps:

1. Determine the lower bound for the number of ‘relations’ needed to solve a puzzle.

2. Determine the minimum number of clues needed to reach that lower bound.

Each cell is related to other 20 cells

Fig4.1: A is related to 20 other cell

Cell ‘A’ cannot be equal to any of the ‘x’ cells.

• Every cell of the Sudoku is then related to exactly 20 other cells. As there are 81

cells, the graph of relations for the puzzle has 810 edges in total. But the 20 relations of a

given cell (A) are redundant, as there are only 8 numbers different than ‘A’, so each number

appears several times in the ‘x’ cells.

Application of Sudoku Puzzle in Encryption and Decryption

Fig4.2: Redundant numbers

Redundant relations are redundant pieces of information. We don’t need redundant

information to solve the graph. Suppose we remove the ‘redundant’ copies of

every relation for every cell, so each cell ends up with 8 ‘relations’:

Fig: Excluding Redundant numbers

The new graph will have 324 edges: 8x81/2 = 324.

Example:

If we consider 16 clues, then the puzzle determines

16*20=320 relations < 324

Application of Sudoku Puzzle in Encryption and Decryption

which is a non-redundant relation. But we need at least 324 to determine a unique puzzle.

So it is not possible to create a unique puzzle with just 16 clues.

For 17 clues, the upper bound for the number of relations is 340, that is bigger than

324. The general formula for any given size can be easily obtained from the above

procedure:

For example, a 9*9 sudoku grid , the number of clues is given as

Application of Sudoku Puzzle in Encryption and Decryption

CHAPTER 5

Implementation:

Software Requirements for implementing the system:

Operating System Windows XP/7/8.1

Platform Net beans IDK 7.1.1

Testing Net beans IDK 7.1.1

Hardware requirements for developing and implementing the system:

A Pentium/Intel based PC with minimum of

I. 1GB RAM

II. 320 GB Hard Disk Space

III. Pentium 4 Processor

Application of Sudoku Puzzle in Encryption and Decryption

Flowchart:

NO

YES

Fig5.1:Flowchart for the

Proposed Algorithm

Start

Put the message

in the blank

Sudoku

Fill the Remaining

blocks/grids to make it a

32-clue puzzle

Select some Random clues

from the solved Sudoku

puzzle to make a new Sudoku

grid.

32

Clues?

To decrypt the message

solve the puzzle

Apply the key

Message is decrypted

END

Application of Sudoku Puzzle in Encryption and Decryption

Experimental Results: In the literature survey we have studied that to be a unique solution of Sudoku, the puzzle

must start with 17 or more clues. But it contradicts in practical. Many a times it result in a multiple

solution providing 17.

Fig 5.2: Solved Sudoku with 17 clues Fig5.3: Solved Sudoku with 17 clues

With 17 clues there will be a unique solution, but it gives multiple solution (Tested in different

Sudoku Solvers). So, the minimum number of clues to be always a unique solution is 32 clues.

With 32 clues it leads to a unique solution without giving any multiple solution.

Fig 5.4: Unique Solution with 32 clues Fig 5.5: Unique Solution with 32 clues

So, the minimum number of clues to be a unique solution is 32.

N no of solution N solution/Unique Single Unique solution

0 16 17 31 32 81

Application of Sudoku Puzzle in Encryption and Decryption

CHAPTER 6

Conclusion:

In this Project, we have use the Sudoku puzzle for Encryption and Decryption. For which we

have used the unique solution of Sudoku. To find the unique solution was the major hurdle we

have faced. Practically, we have found out that it could be found out with a minimum of 32 clue

puzzle. The randomly generated puzzle also acts as a key just like the symmetric key used for

encryption and decryption. If somebody finds only the key then he/she could not decrypt the

message as the randomly generated puzzle is much important as the key.

So, it can be concluded that it is a safe and secure way communication by encrypting the

message inside the Sudoku and decrypting the message from it.

Future Works: It is an open field where we can improve more. As of now we can encrypt numbers as

message and the future works is to find out the way through which we can encrypt alphabet also.

Also, we can improve the key size.

Application of Sudoku Puzzle in Encryption and Decryption

References:

[1] William Stallings, Cryptography and Network Security, 4th ed., PHI, 2006

[2] Atul Kahate, Cryptography and Network Security, Tata McGraw-Hill Education, 2003

[3] The Game of Sudoku-Advanced Backtrack Approach, Abhishek Majumder, Abhay Kumar,

Nilu Das and Nilotpal Chakraborty, IJCSNS International Journal Of Computer Science and

Network Security, VOL.10 No.8, August 2010

[4] The model and algorithm to Estimate the Difficulty Levels Of Sudoku puzzles, Journals of

Mathematics’ Research. Ch. X u, W. X u, 2009

[5] J.F. Crook, A pencil and paper algorithm for solving Sudoku Puzzles, [Cited 2013 February

24],Winthrop University, Webpage: http://www.ams.org/notices/200904/tx090400460p.pdf

[6] Steganography using Sudoku Puzzle Roshan Shetty BR, Rohith J, Mukund V, Rohan

Honwade 2009 International Conference on Advances in Recent Technologies in

Communication and Computing 978- 0-7695-3845-7/09 $25.00 © 2009 IEEE

[7] C.C. Chang, Y.C. Chou and T.D. Kieu, An Information Hiding Scheme Using Sudoku,

Proceedings of the Third International Conference on Innovative Computing, Information

and Control (ICICIC2008), June 2008.

[8] Felgenhauer B, Jarvis F. Enumerating possible Sudoku grids. [Internet]. 2005 [cited 2013

Mar 21]. Available from: http://www.afjarvis.staff.shef.ac.uk/sudoku/

[9] N. Pillay, Finding Solutions to Sudoku Puzzles Using Human Intuitive

Heuristics, South African Research Articles, Webpage:

http://sacj.cs.uct.ac.za/index.php/sacj/article/viewArticle/111

[10] J.F. Crook, A pencil and paper algorithm for solving Sudoku Puzzles,

Winthrop University, Webpage:

http://www.ams.org/notices/200904/tx090400460p.pdf

[11] T. Davis, The Mathematics of Sudoku, Research Article

(http://www.geometer.org/index.html)

[12] Shailender Gupta, AnkurGoyal and Bharat Bhushan, “Information Hiding Using Least

Significant Bit Steganography and Cryptography”, International Journal of Modern

Education and Computer Science, Vol. 6, pp. 27-34, June 2012]

[13] Pasumarthy Saradha and BalaSwamy, “Improving Image Data Hiding Capacity Scheme

using Sudoku Puzzle in Color Images”, International Journal of Engineering Research and

Applications, Vol. 2, No. 3, pp. 2741-2744, May-June 2012. [14] VikasTyagi, Atulkumar, Roshan Patel, SachinTyagi and Saurabh Singh Gangwar, “Image

Steganography using Least Significant Bit with Cryptography”, Journal of

Global Research in Computer Science, Vol. 3, No. 3,pp. 53-55, March 2012.

[15] H. R. Lewis and C. H. Papadimitriou, Elements of theory and computation, 2nd ed., PHI, 1998

[16] C.C. Chang, Y.C. Chou and T.D. Kieu, An Information Hiding Scheme Using Sudoku,

Proceedings of the Third International Conference on Innovative Computing, Information

and Control (ICICIC2008), June 2008.

Application of Sudoku Puzzle in Encryption and Decryption

APPENDIX A: USER INTERFACE

Fig 1: Initial Screen

Fig: The Main Menu

Application of Sudoku Puzzle in Encryption and Decryption

Fig: Message to be Encrypt

Fig: Message inserted in the Sudoku puzzle with symmetric key

Application of Sudoku Puzzle in Encryption and Decryption

Fig: 33-clue puzzle

Fig: Solved Puzzle

Application of Sudoku Puzzle in Encryption and Decryption

Fig: Randomly generated puzzle

Fig: Decryption phase

Application of Sudoku Puzzle in Encryption and Decryption

Fig: Solution to randomly generated puzzle

Fig: Decrypted Message

Application of Sudoku Puzzle in Encryption and Decryption

APPENDIX B: SOFTWARE PACKAGE