Improvement of 32X32 Playfair Cipher using Random Number Generator

4348 words (17 pages) Essay in Computer Science

18/05/20 Computer Science Reference this

Disclaimer: This work has been submitted by a student. This is not an example of the work produced by our Essay Writing Service. You can view samples of our professional work here.

Any opinions, findings, conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of UK Essays.

ABSTRACT

This paper deals with the modification of Playfair cipher.

The existing strategies of Playfair cipher are studied like those enforced on 5X5, 7X4 and 6X6 Playfair matrix.

The study of existing strategies shows that they suffer from many drawbacks like In this paper, the presented encryption mechanism makes the cryptanalysis a very complex process. This has been achieved by first, inserting all the 256 ASCII characters in a sequential order within a 32X32 matrix and, by changing the rotation mechanism for encryption and decryption.  The encrypted text obtained is almost unreadable. 

General Terms

Encryption, Decryption, Plaintext, Ciphertext.

Keywords

Playfair Cipher, Substitution, Cryptography, Network Security, Symmetric Key.

 INTRODUCTION

  1.  Etymologically speaking, the word cryptography comes from the Greek origin. It is a combination of two words Crypto and Graphy. Crypto means Secret and Graphy means Writing. Cryptography is the art of converting plaintext to a cipher text with the help of an encryption algorithm. The process has been depicted in Figure 1. Cryptography is segmented into Symmetric key and Asymmetric key cryptography. It is further defined that same key used for encryption and decryption is called Symmetric key cryptography. Otherwise it is called Asymmetric key cryptography. We will use substitution / replacement Playfair cipher of symmetric key cryptography. The method arranges the plaintext in a table based on a key value, where the key is usually arranged as an N x N matrix.

 

2 PLAYFAIR CIPHER

The Playfair figure was the principal reasonable digraph substitution figure. The plan was developed in 1854 by Charles Wheatstone however was named after Lord Playfair who advanced the utilization of the figure. The strategy scrambles sets of letters (digraphs), rather than single letters as in the basic substitution figure. The Playfair is fundamentally harder to break since the recurrence examination utilized for basic substitution figures does not work with it. Recurrence examination can at present be attempted, yet on the 25*25=625 potential digraphs instead of the 25 potential monographs. Recurrence examination accordingly requires substantially more ciphertext so as to work.

Get Help With Your Essay

If you need assistance with writing your essay, our professional essay writing service is here to help!

Find out more

It is a symmetric substitution figure for example a solitary key is utilized for both encryption and unscrambling. A Playfair cipher uses a 5X5 matrix and encrypts pairs of letters called digraphs. The 5 by 5 table contains a key word or phrase. The table is generated by first filling in the spaces with the letters of the keyword without including any duplicate letters and then filling in rest of the letters in alphabetical order. „I‟ and „J‟ are set in same section with the goal that all the 26 characters can be filled in a 5X5 network. The encryption in a Playfair figure is finished by utilizing the accompanying procedure.

 This process is also known as the conversion process:

1. If a digraph contains same letters then add an „X‟ between them and re-pair the letters.

 2. If the letters of the digraph appear consecutively in a row then replace them with the letters to their immediate right. In case the letter is the last letter in the row, than replace it with first letter from the left of the same row.

 3. If the letters of the digraph appear consecutively in a column then replace them with the letter to their immediate below. In case the letter is the last letter in the column, than replace it with first letter from the top of the same column. 

4. If the letters are on different rows and columns, replace them with the letters on the same row such that, they lie in column of the other letter. Replacing the first letter of the digraph first. 

2.1 Limitations of 5X5 matrix:

  • It considers the letters I and J or L and M as one character.
  • 26 letters alone can take as keyword without duplicates.
  • Space between two words in the plaintext is not considered as one character.  It cannot use special characters and numbers.
  • It only uses uppercase alphabets.
  • A spare letter X is added when the plaintext word consists of odd number of character. In the decryption process this X is ignored. X is a substantial character and makes disarray since it could be a piece of plaintext, so we can’t just expel X in unscrambling process.

• X is utilized a filler letter while rehashing letter falls in a similar pair are isolated.

 

 

3.PROPOSED METHOD

In the proposed method a 32X32 matrix is being used in which the matrix is shifted by some random value, due to which the corresponding positions of the letters are changed. This random number can lie between 0 and 32. It can be manually entered by the user and also can be generated by a random number generator function. The random number generated rotates the matrix by that particular value.

3.1 The Encryption algorithm:

1. Read the keyword.

2. Eliminate the repeated characters in keyword.

3. Construct a 32X32 matrix by filling the character of keyword from left to right and top to bottom. 4. Fill the token of network with the rest of the characters from ASCII esteems 0 to 255.

5. Peruse a plaintext.

6. Separation the plaintext into pair of characters.

7. Add the character “Null” when odd number of characters are present in the message.

8. Generate a random number using RAND function.

9. Shift the matrix from top to bottom towards left circularly by the first generated random number.

10. Encrypt the first diagraph using the following modified conversion process: a) If a digraph contains same letters then add a „*‟ between them and re-pair the letters. b) If the letters of the digraph appear consecutively in a row then replace them with the letters to right, shifted by the value of random number generated. In case the letter is the last letter in the row, then replace it with that letter which is random number position from the left of the same row. c) If the letters of the digraph appear consecutively in a column then replace them with the letters below, shifted by the value of random number generated. In case the letter is the last letter in the column, then replace it with that letter which is random number position below in the same column. d) If the letters are on different rows and columns, replace them with the letters on the same row such that, they lie in column of the other letter. Replacing the first letter of the digraph first. 

11. Generate another random number and rotate a matrix by making a left shift circularly with the generated random number. Then encrypt another digraph using the conversion process and so on.

12. Send all the random numbers generated to the receiver.

3.2 The Decryption algorithm:

1. Read the keyword.

2. Eliminate the repeated characters in keyword.

3. Construct a matrix by filling the character of keyword from left to right and top to bottom.

4. Fill the reminder of matrix with the remaining characters from ASCII values 0 to 255.

 5. Read the ciphertext.

 6. Divide the ciphertext into pair of characters.

 7. Add the character “Null” when odd number of characters in the message. Use the received random numbers in reverse order to rotate the matrix. 

8. Use the lastly generated random number to rotate the matrix from bottom to top using right shift circularly then decrypt firstly the last diagraph.

9. Again use the second last generated random number to rotate the matrix and decrypt the second last diagraph and so on in reverse order of diagraph and random number.

10. Decrypt using the conversion process.

11. Finally reverse the string and obtain the plaintext.

4. DEVLOPMENT OF THE MATRIX

The initial matrix would be developed by first taking a 32X32 matrix and then filling the matrix with all the ASCII values in a sequential manner. The complete matrix obtained has been depicted in Table 1 [7].  Let the keyword be: Play:5⇗. On inserting the keyword in the matrix, Table 2 is obtained. Let the plaintext be Dell. Since „l‟ occurs consecutively, we separate them with a „*‟ obtaining 3 diagraphs:

 De    l*      l*

Initially, let the random number generated be 4 so that the matrix will be rotated circularly left by 4 positions as shown in Table 3. Now, to encrypt the second digraph the above obtained Table 3 is rotated by random number 6 (say) by which we obtain Table 4. 

Using the conversion process on Table 4, the cipher text of the second digraph „l*‟ is obtained as „P+‟

Similarly, in order to encrypt the third digraph, the above obtained Table 4 is rotated by random number 8 thus, obtaining Table 5. 

Using the conversion process, the cipher text of the third digraph „l‟* is also obtained as „P+‟.

Thus, „Dell‟ is encrypted to „CfP+P+‟

AN ILLUSTRATIVE EXAMPLE OF  9 X 9 PLAYFAIR CIPHER

The purpose of this example is to illustrate the functioning of a 9 x 9 of Playfair cipher matrix, but the concept can be extended to any size of matrix. The 9 x 9 Playfair cipher uses 9 x 9 matrix which contains the key at the beginning of the matrix. The key should not be more than 81 characters (pertaining to the size 9 x 9) decided by the security administrator.  Let us take the following example to understand the functioning of the 9 x 9 Playfair cipher. In the model, the key is “Playfair figure model”.

To put the key in the matrix, following steps are taken: 

1. First, remove the spaces from the key. 

2. Then, remove the duplicate character that is in the key.

3. Finally, insert the key characters at the beginning of the matrix followed by the rest

of characters that are not part of the key character.   The subsequent 9 x 9 grid is portrayed in Figure1.

A. Encryption

To encrypt a given plaintext using 9 x 9 Playfair cipher,

following steps are taken. 

  1. Replace the spaces in the plaintext by “BMW”

2. Replace the repeated letter by “AOX” and if the number of characters is odd, add “AOX” at the end of the plaintext.

FIG. 1 A 9 X 9 MATRIX WITH THE KEY “PLAYFAIR CIPHER EXAMPLE”

3. Break the plaintext into digraphs (groups of 2 letters), then apply the following rules to encrypt the plaintext:

a. If the two letters appear in the same row of the matrix, replace them with other letters

that are on the right of them (if the letter is at the end of the row take the letter that is

in the beginning of the row).

b.  If the two letters appear in the same column of the matrix, replace them with

other letters that are below them (if the letter is in bottom of the column take the

letter that is on top of the column)

c. If the two letters are not on the same row or column, replace them with the letters on the

same line separately yet at the other pair of corners of the square shape characterized by the unique pair. The request is significant – the primary letter of the encoded pair is the one

that lies on a similar line as the primary letter of the plaintext pair. As an example, consider encrypting the plaintext “My bird is  on the  treeLU”. Replace  each  space  by  “BMW” and  replace  one  of  the  duplicated  letters  by  “AOX”  as

follows:

MyBMWbirdBMWisBMWonBMWtheBMWtrAOXeLU

Then, encrypt each 2 letters separately as follows: 

My BM Wb ir dB MW is BM Wo nB MW th eB MW tr AO Xe LU. 

Note the in  the example  above, BMW  was used  to replace the spaces in the plaintext and AOX was used to replace  the repeated  letter  and  for  single  last  pair. The reason for doing this is the following.  

  • If spaces or duplicated letters are replaced by one character (e.g.  X, O,  ^) or  any  other character,but if the same character is part of the plaintext, it will be replaced by space or duplicate the next character in the decryption side.
  • If we add two characters to  an odd  plaintext, it will  result  in another  odd  plaintext  rather than even (to encrypt it as pair).

So,  to  solve  the  above  problems,  three  different characters were used to replace the spaces in the plaintext and to replace the repeated letter and for single last pair.

Let  us  see  how  each  pair  in  the  above  example plaintext will be encrypted.

1. The pair My forms a  rectangle (by applying rule 3c from Section II-A), replace it with Jr (see Fig. 2).

2. The  pair  BM  forms  a  rectangle  (rule  3c), replace it with DK (see Fig. 2).

3. The  pair  Wb  forms  a  rectangle  (rule  3c), replace it with Rn (see Fig. 2).

 4. The pair ir is in same row (rule3 a), replace it with rc.

 

5. The  pair  MW  forms  a  rectangle  (rule  3c), replace it with NV.

6. The  pair  is  forms  a  rectangle  (rule  3c), replace it with lw.

7. The  pair  BM  forms  a  rectangle  (rule  3c), replace it with DK.

8. The  pair  Wo  forms  a  rectangle  (rule  3c), replace it with Xn.

9. The  pair  nB  forms  a  rectangle  (rule  3c), replace it with gE.

10. The  pair  MW  forms  a  rectangle  (rule  3c), replace it with NV.

11.  The  pair  th  forms  a  rectangle  (rule  3c), replace it with

 12.  The pair eB is in same row (rule 3a), replace it with xC.

13. The  pair  MW  forms  a  rectangle  (rule  3c), replace it with NV.

14. The  pair  tr  forms  a  rectangle  (rule  3c), replace it with za.

 

15. The  pair  AO  forms  a  rectangle  (rule  3c), replace it with FJ (see Fig. 3)

16.  The  pair  Xe  forms  a  rectangle  (rule  3c), replace it with PF  (see Fig. 3).

17. The pair LU is in same row (rule 3a), replace it with Uj  (See Fig. 3).

The resulting ciphertext will be as follows:

JrDKRnrcgANVlwDKXngENV|axCNVzaFJPFUj 

B. Decryption

To decrypt the ciphertext on the receiver side, use the inverse (opposite) steps that were done in the encryption side, and the original correct plaintext will be recovered.

3. RESULTS AND ANALYSIS OF VARIOUS MATRIX SIZES FOR THE KEY

Different  sizes  of  the  matrices  for  the  key  were implemented  ranging  from  9  x  9  to  11  x  11.  The characters  contained  in  these  matrices  (without  any specific key) are shown in Figures 4(A) and 4(B) for 10 x 10 and 11 x 11 respectively (note that an example of 9 x 9 is already given in Fig. 1, but with a specific key, although all 81 characters are there).  Accordingly, a 10 x 10 matrix contained 100 characters, and an 11 x 11 matrix consisted of 121 characters.  Two set of experiments were done. In the  first set,  the plaintext  was variable  but the key was kept the same. In the second set, the plaintext was kept the same but the  key was changed. For both sets, avalanche effect  was  measured.  Avalanche  effect  measures  the change in the output when the input or the key is slightly changed [13].  Details of these experiments and results are given below.

The change in the output characters ranged between 1 and 12 characters.  A clearer picture of the trends is visible which shows that an increase in the size of plaintext does not contribute much to the avalanche effect. The reason for this is that there is only one-bit change in the whole plaintext input, and this one-bit change does not depend on the size of the plaintext.  Moreover, it is also observed that for all three matrix sizes, the biggest change was observed for plaintext of 75 characters. This could be attributed to the structure of the plaintext itself, which, in this case, might have a strong impact on the output due to the particular key selected for encryption.

5. CRYPTANALYSIS

In 5×5 Playfair cipher, cryptanalysis is done through two processes. First is brute force attack and second is frequency analysis. In brute force attack we apply several permutation and combinations while in frequency analysis number of occurrences of letters in English alphabets are found and compared to maximum occurrence of each letter in plaintext. Also, the number of permutations applied on each digraph is 676 combinations, which can be easily broken in few hours. But in 32×32 Playfair, as we are using all the 256 ASCII values which will take more time to apply brute force attack.

Find out how UKEssays.com can help you!

Our academic experts are ready and waiting to assist with any writing project you may have. From simple essay plans, through to full dissertations, you can guarantee we have a service perfectly matched to your needs.

View our services

on each pair of diagraphs because each diagraph takes 676 combinations. The frequency analysis of 32×32 is very typical, as the frequency analysis of alphabets is available but not that of ASCII symbols.  Also, in the proposed method, the conversion process has been slightly altered i.e. in the original conversion process; if the letters of the digraph appear consecutively in a column then they are replaced with the letter to their immediate below. In case the letter is the last letter in the column, then it is replaced with first letter from the top of the same column.  But in the proposed method, if the letters of the digraph appear consecutively in a row then replace them with the letters to right, shifted by the value of random number generated. In case the letter is the last letter in the row, than replace it with that letter which is random number position from the left of the same row. If the letters of the digraph appear consecutively in a column then replace them with the letters below, shifted by the value of random number generated. In case the letter is the last letter in the column, than replace it with that letter which is random number position below in the same column.

6. CONCLUSION

The implementation of advanced encryption algorithm generates cipher text which is very complex. It is concluded that by changing the encryption mechanism by including a random number, the complexity of the encrypted text can be significantly increased. 

Playfair cipher has a strong potential for usage in wireless and mobile communications in which the sender is constrained by limited power. This potential of Playfair cipher lies in its simple design which allows for less power consumption than more complex algorithms such as RSA, DES, and AES. The results indicate that the avalanche effect does not depend on the size of the plaintext itself.  However, there may be notable changes in the output with plaintext of certain sizes, but no change with other plaintext of the same size. This strongly depends on the plaintext itself and the order (position) of the characters it contains in the matrix.  Furthermore, bigger key sizes have a stronger impact on the output compared to smaller key sizes.

 Table 6: Comparison between Proposed and Existing method

        Properties

            Existing Methods

         Proposed Method

        (32×32)

1

Encryption technique

             Normal

          Modified

2

Frequency Analysis

Possible with alphabets

     Not easy due to symbols

3

Key size

          25,36,38

            1024

4

Matrix size

           25,36,28

             1024

5

Random numbers

          Not used

              Used

6

Rotation

          Not used

              Used

The above depicted table clearly shows the difference between existing methods of encryption used in 5X5, 6X6, 7X4, 32X32 matrix and proposed method that changes the encryption mechanism and increases the key size.

The advantages of proposed method can be enlisted as follows: 

  • The conversion process has been altered which enhances the complexity of the ciphertext.
  • The matrix is rotated by a certain random number before encrypting.
  • It allows more than 26 characters as keyword.
  • The letters „I‟ and „J‟ are not treated as same characters.
  • It considers the space between two words in plaintext as one character.
  • This proposed scheme is case sensitive.
  • The user can easily encrypt and decrypt the combination of alphabets, numbers and special characters efficiently at the same time, the complexity of cryptanalysis is uncompromised. It can be safely concluded that the proposed method is very much efficient than the existing method by the virtue of its extended matrix, increased key size and modified encryption mechanism. 

 

7  REFERENCES

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

[2] William Stallings, “Cryptography and Network Security                Principles and Practice”, 4th Edition, Prentice Hall,2006.

 [3] Aftab Alam, Sehat Ullah, Ishtiaq Wahid, & Shah Khalid “Universal Playfair Cipher Using MXN Matrix”.  International Jourrnal of Advanced Computer Science,  Vol.1, No.3, Pp.113-117, Sep.2011. [4] Ravindra Babu K, S.Uday Kumar, A. Vinay Babu, I.V.N.S. Aditya, P.Komuraiah, “An Extension to Traditional Playfair Cryptographic Method”. International Journal of Computer Applications (0975 – 8887), Volume 17- No.5, March 2011.

 [5] Muhammad Salam, Nasir Rashid, Shah Khalid, Muhammad Raees Khan, “A NXM Version of 5X5 Playfair Cipher for any Natural Language (Urdu as Special Case)”. World Academy of Science, Engineering and Technology 73 2011.

 [6] A. Aftab Alam, B. Shah Khalid, and C. Muhammad Salam, “A Modified Version of Playfair Cipher Using 7×4 Matrix”. International Journal of Computer Theory and Engineering, Vol. 5, No. 4, August 2013.

 [7] S.S.Dhenakaran, M. Ilayaraja, “Extension of Playfair Cipher using 16X16 Matrix”. International Journal of Computer Applications (0975 – 888) Volume 48– No.7, June 2012.

 [8] Arvind Kumar, Pawan Singh Mehra, Gagan Gupta, Aatif Jamshed, “Modified Block Playfair Cipher using Random Shift Key Generation”. International Journal of Computer Applications (0975 – 8887) Volume 58– No.5, November 2012 .

32×32 Matrix

Cite This Work

To export a reference to this article please select a referencing style below:

Reference Copied to Clipboard.
Reference Copied to Clipboard.
Reference Copied to Clipboard.
Reference Copied to Clipboard.
Reference Copied to Clipboard.
Reference Copied to Clipboard.
Reference Copied to Clipboard.

Related Services

View all

DMCA / Removal Request

If you are the original writer of this essay and no longer wish to have the essay published on the UK Essays website then please:

Related Lectures

Study for free with our range of university lectures!