You are on page 1of 5

# International Journal of Advanced Computer Science, Vol. 1, No. 3, Pp. 113-117, Sep.

2011

## Universal Playfair Cipher Using MXN Matrix

Aftab Alam, Sehat Ullah, Ishtiaq Wahid, & Shah Khalid

Manuscript
Received: 28, July., 2011 Revised: 9, Aug., 2011 Accepted: 25, Aug., 2011 Published: 30, Sep. 2011

Keywords
cryptography, Plain text, Cipher text, Encryption Algorithm, Decryption Algorithm, key, substitution cipher, transposition cipher, Playfair cipher.

Abstract Cryptography plays an important role in todays digital world. For the purpose of security and privacy, we need to encrypt the message at the sender side and decrypt it at the receiver side. This paper deals with the modification of playfair cipher. The original 5x5 matrix playfair cipher is modified to mxn matrix playfair cipher in which two symbols * and # are included. The addition of these two symbols in the matrix creates one-to-one correspondence between the plain text and the Cipher text, which makes the encryption and decryption easy and unambiguous. The text becomes more secure when these symbols appear in the resulting Cipher text. The proposed method can be used to encrypt and decrypt the messages of any natural language by taking a proper size matrix. For some european languages if the decrypted message contain characters superscripts or subscripts with special symbols (e.g.,), it will be read by the machine in the same accent as by the human being.

used as input by the encryption/decryption algorithm to encrypt/decrypt the message. The process of converting plain text into Cipher text is called enciphering or encryption while restoring the plain text from the Cipher text is called deciphering or decryption. The process of encryption and decryption is shown in Fig. 1.
Key Key

Plain

Text

Encryption Algorithm

Cipher Text

Decryption Algorithm

Plain

Text

## Fig. 1. Encryption/Decryption Process

1. Introduction
Cryptography is a Greek word which means secret writing [1]. Today this term refers to the science and art of transforming messages to make them secure and immune to attacks [2]. For the purpose of security and privacy, we need to encrypt the message at the sender side and decrypt it at the receiver side. So cryptography is the study of creating and using encryption and decryption techniques. In cryptography the term plain text is used for the original message that is to be transformed. The message which has been transformed is called Cipher text. An encryption algorithm is a function that works with a key to transform the plain text into Cipher text. Decryption algorithm works in the reverse order and converts the Cipher text into plain text with the help of key. A key is a defined value which is
This work was supported by university of Malakand K.P.K Pakistan. A. Alam, S. Ullah, I. wahid, and S. Khalid ({alam, sehatullah, ishtiaqwahid, shahkhalid }@gmail.com)

Cryptography is divided into two types, Symmetric Key Cryptography and Asymmetric Key Cryptography [1]. In Symmetric Key Cryptography a single key is shared between sender and receiver. The sender uses the shared key and encryption algorithm to encrypt the message. The receiver uses the shared key and decryption algorithm to decrypt the message. In Asymmetric Key Cryptography each user is assigned a pair of keys, public key and private key. The public key is announced to all members while the private key is kept secret by the user. The sender uses the public key of the receiver to encrypt the message. The receiver uses his own private key to decrypt the message.

## Fig. 2. Types of Cryptography [3]

In Symmetric Key Cryptography two types of ciphers, substitution cipher and transposition cipher are used [2]. In substitution cipher one symbol of the plain text is replaced by another symbol. Substitution cipher has further two types. Monoalphabetic substitution cipher, in which a character in the plain text is always changed to the same character in the Cipher text. The well known example of Monoalphabetic substitution cipher is the CAESAR cipher

114

International Journal of Advanced Computer Science, Vol. 1, No. 3, Pp. 113-117, Sep. 2011.

which always change a to d. In polyalphabetic substitution cipher a single character in the plain text is changed to many characters in the Cipher text. The well-known example of polyalphabetic substitution cipher is VIGENERE cipher which changes a single character in the plain text into many characters in the Cipher text by considering the position of character in the plain text. In transposition cipher the characters in the plain text are swapped to get the Cipher text i.e. the characters retain their plain text form but their position is changed. The plain text is organized into two dimensional table and columns are interchanged according to a predefined key.

2. Related Work
Encryption is a primary method for securing electronic data. It is the process of transforming a piece of information into unreadable form for an unauthorized user. The two basic building blocks of encryption techniques are substitution and transposition. In substitution method letters in the plain text are replaced by other letters or symbols while in transposition method characters in the plain text are swapped to get the Cipher text [4]. The well-known examples of substation ciphers are Caesar cipher, playfair cipher, Hill cipher and Vigenere cipher [5]. Caesar cipher involves replacing each letter of the alphabet with letter standing three places further down the alphabet. For example a will always be changed to d and b will always be changed to e. The Playfair cipher is a polygraphic cipher which enciphers two letters at a time. Hill is another multiletter cipher. The encryption algorithm takes k successive plain text letters and substitute for them k cipher text letters. Vigenere cipher is polyalphabetic substitution cipher in wich a single plain text letter can be converted into multiple cipher text letters. This conversion depends on the position of the letter in the plain text e.g. c may be converted into g because it is at position 3 in the plain text but c can be changed into z because its position in the plain text is 5. Modern ciphers use both substitution and transposition to encrypt the message that increases the security of data. The data is encrypted in blocks instead of single characters at time. The well-known example of block cipher is Data Encryption Standard (DES). DES uses 56-bits key and encrypt 64-bits of data as a single block. The attacker uses various methods to get the plain text from the cipher text. They try to find out the way in which plain text is converted into cipher text and the encryption key used. Various methods were used for identifying ciphers. Identification of permutation, substitution and Vigenre ciphers was done using frequency analysis [6]. An attempt was made to identify block ciphers like DES and Blowfish using pattern recognition methods [7]. Other ciphers like stream cipher SEAL and Enhanced RC6 have been identified using neural networks [8].

originally developed by Charles Wheatstone in 1854 but it bears the name of Lord Playfair because he promoted the use of this method [9]. Playfair is digraph substitution cipher which uses a 5x5 matrix, in which the key word is written first and the remaining cells of the matrix are filled with other letter of alphabets, while I and J are placed in the same cell. The message is divided into digraphs, in which repeating letters in the same pair are separated by filler letter X. In case of odd number of letters in the message a spare letter X is padded with the word to complete the pair. Then the plain text is encoded according to the four rules presented in [10]. Any word with no repeating letters can be selected as a key word to fill the matrix. The problem arises when the letter I or J appears in the key word. Suppose we choose the key word CIPHER and take the L and M in the same cell as shown in Table 1.
TABLE 1 SHOWS 5X5 MATRIX IN WHICH L AND M ARE PLACED IN THE SAME CELL. THE KEY WORD IS CIPHER.

C R G O V

I A J Q W

P B K S X

H D L/M T Y

E F N U Z

Now we encrypt the message LOVE ALL PEOPLE using the rules of the playfair cipher presented in [10]. Plain text: Diagraphs: Cipher text: LOVE ALL PEOPLE LO VE AL LP GT ZC DJ KH EO PL CU HK EX PZ

The decryption of the above Cipher text generates two valid English sentences.

## Fig. 3. shows the decryption process

Considering the first digraph GT in the Cipher text it is obvious from the mapping in Fig. 3. that G can be replaced by L and M. We get the original plain text LOVE ALL PEOPLE if G is replaced by L. But if G is replaced by M, we get the plain text MOVE ALL PEOPLE which is also a valid english sentence.

## 4. The Modified Version of Playfair Cipher

The problems in 5x5 matrix playfair cipher arise when either I or J, or both appear in the key word. Also when the plain text word consist of odd number of characters, a spare letter X is padded with the word to complete the pair. In the decryption process this Xis simply ignored. This
International Journal Publishers Group (IJPG)

## 3. The Playfair Cipher

Playfair is a substitution cipher. Playfair cipher was

## Alam et al.: Universal Playfair Cipher Using MXN Matrix

115

creates confusion because X is a valid character and it can be the part of plain text, so we cannot simply remove it in the decryption process. In this study we proposed 7x4 matrix playfair cipher which efficiently handles these problems. In 7x4 matrix playfair cipher any word with no repeating letter can be selected as a key word. The remaining spaces are filled in order with the rest of alphabets. The second last cell is filled with the symbol * and the last cell is filled with the symbol # as shown in the Table 2.
TABLE 2 SHOWS 7X4 MATRIX WHICH IS THE MODIFICATION OF 5X5 MATRIX. EACH CELL OF THE MATRIX CONTAINS A DISTINCT CHARACTER. THE KEY WORD IS CIPHER.

encryption and decryption process special symbols also appears which enhances the security of information.

## 5. Universal Payfair Cipher

The proposed method presented in section 4 can be extended to make the playfair Cipher universal i.e the playfair cipher can be used for the encryption and decryption of any natural language. The following steps are applied. Determine the number of characters k in the natural language. Identify the size M (M=k+2) of the matrix which can accommodate all characters of the language. Select the key having no repeating character. Fill the cells of matrix accordingly. The second last cell is of the matrix is filled with the symbol * and the last cell is filled with the symbol # . Make digraphs of the plain text. Use # for completing the odd pair and * for repeating characters. Encrypt the message according to the rules presented in [10]. In the decryption process ignore the symbols * and # to get the original plain text. Determine k (Number of characters and special symbols in the natural language)

C E D K O U Y

I R F L Q V Z

P A G M S W *

H B J N T X #

To encrypt the plain text, the same rules presented in [10] are followed with the following modification. If both letters are same in a digraph, add a * after the first letter, so a BALLOON will be treated as BA L* LO ON. If a word consists of odd number of letters, add the symbol # to complete the pairs. So ALL become AL L#. The # is simply ignored when the Cipher text is decrypted. Now we encrypt the message LOVE ALL PEOPLE using modified playfair cipher. Plain text: Diagraphs: Cipher text: LOVE ALL PEOPLE LO VE AL LP KQ UR RM MI EO DU PL IM E# BY

## Calculate size M of the mxn matrix (M=K+2)

Read the plain text and Key word and construct the mxn matrix accordingly

By decrypting the above Cipher text and ignoring the # symbol, we get a single sentence LOVE ALL PEOPLE which is the original plain text message. The mapping of the Cipher text into plain text is shown in Fig. 4. The correspondence between Cipher text and plain text is one-to-one. So there is no confusion in the decryption process.

## Encrypt the message

Cipher text
Fig. 5. Model of Universal Playfair Cipher

Fig. 4. shows the decryption process. The relationship between plain text and cipher text is one-to-one

The beauty of the proposed method is that it can be applied to encrypt and decrypt the messages of any natural language [11]. A proper size matrix is selected which accommodate all the alphabets of language along with special symbols that are used in the language. In the
International Journal Publishers Group (IJPG)

A. Case Study 1: Encryption and decryption of Urdu language text with Universal Playfair Urdu is the national language of Pakistan which consists of 40 characters. To encrypt/decrypt the message in Urdu we need a matrix of size 42 (7X6). Following is the example of encryption and decryption process for Urdu language using the proposed idea. Consider the following Urdu plain text:

116

International Journal of Advanced Computer Science, Vol. 1, No. 3, Pp. 113-117, Sep. 2011.

symbol, we get il a achet une pomme which is the original plain text message in the French language. Key:

6. Cryptanalysis
In cryptography, confusion and diffusion play an important role in the development of a cipher [12,13,14]. Confusion refers to making the relationship between the key and Cipher text as complex as possible and can be achieved by transposition. Diffusion refers to making the relation between the plain text and Cipher text as complex as possible. Strong confusion and diffusion make it difficult for the attacker to find the key or plain text if the attacker has large number of plain text and Cipher text pairs. Like the original playfair cipher, the algorithm proposed in this study can also be easily cracked if someone has enough Cipher text and plain text pairs. The addition of the * and # symbols have greatly increased the diffusion but still the proposed algorithm can be cracked by the same methods as the original 5x5 matrix playfair.

Digraphs:

Cipher text:

Plain text:

Now drop the symbols * and # to get the original plain text.

## 7. Conclusion and future work

In this paper the original 5x5 matrix playfair cipher is modified to mxn matrix playfair cipher. The symbols *and # are included in the matrix which create one-to-one correspondence between the plain text and the Cipher text. So the encryption and decryption process is unambiguous and easy. The beauty of the proposed method is that it can be applied to any language by just taking a proper size matrix, which can accommodate all alphabets of that language. Modern ciphers such as DES use both substitution and transposition to encrypt the messages. This increases the security of information by making the text more unreable. The future work shall consider this hybrid approach for the Universal Playfair Cipher which will further strengthen the security of the proposed method.

.
B. Case Study 2: Encryption and decryption of French language text with Universal Playfair Cipher In European languages for example French, if certain characters have superscripts or subscripts with special symbols (e.g. a, , , ) then it produce different sounds than the normal character. For example is pronounced as a. similarly ca produces the sound of ka but a is pronounced as sa which means it or this. If these characters are included in the matrix and then encryption/decryption process is applied, each character will decrypt into its corresponding alphabet. The advantage of this method is that the decrypted message will be read by the machine in the same accent as by the human being. For example a french sentence il a achet une pomme which means he bought an apple can be encrypted as follow.
TABLE 3
SHOWS 8X6 MATRIX WHICH IS USED FOR THE ENCRYPTION AND DECRYPTION OF FRENCH LANGUAGE TEXT. THE KEY WORD IS VLO.

Acknowledgement
We are very thankful to Almighty Allah; whose grace and blessed mercy enabled us to complete this work with full devotion and legitimacy. We are grateful to Mr. Fakhruddin Department of Computer Science and IT, University of Malakand for their invaluable support and guidance throughout this research work. We also want to thank our friends and family for their encouragement; without whose support we could not have lived through this dream of ours.

v c i q x

d j r y

l e k s z [ a

o f m t b

a g n u *

b h p w c #

References
[1] [2] [3]
Andrew S. Tanenbaum, Networks Computer, 5th edition, Pearson Education, ISBN-10: 0132553171.

Key word: vlo which means cycle. Plain text: il a achet une pomme. Diagraphs: il a# ac he t un e# po m* me Cipher text:kv b* vg cf ro u h mb n kf By decrypting the above Cipher text and ignoring the *

Behrouz A .Forouzan, Data Communications and Networking, 4th Edition, McGraw-Hill's, ISBN-10: 0073250325, 2006. M. Salam, N. Rashid, S. Khalid, & M.R. Khan A NXM Version of 5X5 Playfair Cipher for any Natural Language, International Journal Publishers Group (IJPG)

117

[4] [5]

## [12] [13] [14]

(2011) World Academy of Science, Engineering and Technology, vol. 73, pp. 889-891, Dubai. Stamp M. Information Security: Principles and Practice, 2nd Edition, John Wiley & Sons Inc. ISBN: 978-0-470-62639-9, May, 2011. G. Sivagurunathan, V. Rajendran, & T. Purusothaman Classification of Substitution Ciphers using Neural Networks, (March, 2010) International Journal of Computer Science and Network Security, vol. 10, no. 3, pp. 274-279. Pooja Maheswari Classification of ciphers, (2001) Indian Institute of Technology, Kanpur. Sreenivasulu Nagireddy A Pattern recognition approach to block cipher identification, (2008) Indian Institute of Technology, Chennai. B. Chandra & P. Paul Varghese, Application of cascade correlation Neural Network for cipher system Identification, (2007) World Academy of Science, engineering and technology. David Shallcross, The Playfair Cipher, (2008) Vinculum, vol. 45, no. 2, Pp. 4-6, ISSN: 0157-759X. Stallings W., Cryptography and Network Security: Principles and Practice, 4th Edition, Prentice Hall, ISBN-10: 0131873164, 2005. A. Alam, S. Khalid, & M. Salam, A Modified Version of Playfair Cipher Using 7x4 Matrix, (October 17-19, 2010) IEEE International Conference on Software and Computing Technology (ICSCT2010), vol. 2, pp. 36-38, Kunming, China. H.A.A. Hassan, M. Saeb, & H.D. Hamed, The PYRAMIDS block cipher," (2005) International Journal of Network Security, vol. 1, no. 1, pp. 52-60. Y. Kurniawan, A.S.A., M.S. Mardiyanto, I.S.S., & S. Sutikno, The new block cipher: BC2," (2009) International Journal of Network Security, vol. 8, no.1, pp. 16-24. P. Lin, W.L. Wu, & C.K. Wu, Security analysis of double length compression function based on block cipher," (2007) International Journal of Network Security, vol. 4, no. 2, pp. 121-127.

Sehat Ullah was born in 1977 in Pakistan. He got MSc degree in Computer science from university of Peshawar, Pakistan in 2001. He did his MS degree in Virtual Reality and intelligent systems from the University of Evry, France in 2007. He got PhD degree in robotics from the same university in 2011.Currently he is working as assistant professor in the department of computer science, University of Malakand Pakistan.
Ishtiaq Wahid was born in Ouch, Pakistan in 1984.He received his B.S. degree in information technology from University of Malakand at Chakdara, Dir lower, KPK, Pakistan, in 2007 and M.S. degree in Computer Science from Iqra University Islamabad Pakistan in 2009. He is currently pursuing his Ph.D from Department of Computing and Technology Iqra University Islamabad Pakistan . He joined University of Malakand as a lecturer in 2010. His current research interests include Ad-hoc networks, wireless communications, and virtual reality environment.

Aftab Alam was born in Chakdara, Pakistan, in 1982. He received his BS-IT (Hons) degree from University Of Malakand, Pakistan in 2007 and MS(CS) degree from FSAT-NU, Pakistan in 2010, with specialization in Networking. Currently he is perusing his Ph.D from University of Malakand, Pakistan. His current research interests include information security, next generation networks, 3D Graphics and Bioinformatics.

Shah Khalid was born in Tekni Payeen,Pakistan in 1981. He received his M.Sc degree in Computer Science from University of Peshawar, Pakistan in 2004 and now perusing his M.S. degree in Computer Science from Abaseen University, Pakistan. Currently he is working as Lecturer in the department of computer science, University of Malakand Pakistan. His current research interests include wireless and mobile communications, network security and virtual reality environment.