Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

network security
communitycreator
play fair

Encryption using Playfair Cipher

Adithya Challa

Overview

The best-known multiple letter encryption cipher is the Playfair.

It is a symmetric-encryption technique that was invented in 1854 by Charles Wheat Stone. The Playfair treats diagrams in plaintext as single units and translates them into ciphertext. The Play-Fair algorithm uses a 5x5 matrix of letters called Playfair square or Wheatston-square, constructed using keyword.

Note:

  • Keyword: Gitam University
  • Plain Text: Gaming academy

Steps for filling a matrix:

Procedure

  • The keyword is filled from left to right in the matrix.

  • Here i/j is supposed to be placed in a single block since there are 26 letters in English.

  • Only i/j are supposed to be placed in a single block.

  • Repeated letters are ignored.

  • After filling the keyword, the remaining letters are filled in alphabetical order.

Rules

  1. Divide Plain text into pairs of letters.

Note: Plain Text: ga|mi|ng|ac|ad|em|yx. When a letter is left alone, we can add “x” in the end.

  1. If a pair contains repeated letters, we can use a filler letter such as x:

Note:

  • Ex: “hello” he|lx|lo
  • Ex:“balloon” ba|lx|lo|on
  1. If two letters are in the same row, replace them with the immediate right.

  2. If two letters are in the same column, replace them with immediate below.

  3. If two letters are not in the same row or column, we draw a rectangle enclosed with those letters.

  4. If two letters are in the same row, but there is no letter to the right, we return to the first letter from the left.

Output

  • PLAIN TEXT: |GA|MI|NG|AC|AD|EM|YX|
  • CIPHER TEXT: |IM|GT|UI|EL|MC|RA|CQ|

Note: Since I/J are in the same cell, we can use either I or J throughout while solving. So, we can have an output even in this way: |JM|GT|UJ|EL|MC|RA|CQ|

Limitations

  • The Play Fair Cipher is a great advance over simple monoalphabetic ciphers, but even here it has 26x26=676 diagrams.
  • So, Identification of individual diagrams is not
    difficult at present.
  • In today’s time, Playfair cipher is easily breakable by using statistical or brute-force methods.

Playfair implementation

Playfair cipher

Explanation

  • As discussed in the rules, the plaintext is divided into |GA|MI|NG|AC|AD|EM|YX|.
  • We create a PlayFair matrix using Keyword “Gitam University.”
  • Now, both G and A are in the same row, so we take the immediate next to them: I/J and M.
  • Similarly, M and I are in the same row; No letter is present next to. So, we move to the immediate left, which is G. The next to I/J is T.
  • N and G are neither in the same row nor a column, so we draw a rectangle enclosing both the letters.
  • We consider the next of N as U and G as I/J.
  • A and C are in the same column, so we take the next letter in the E and L columns.
  • A and D are neither in the same row nor a column, so we draw a rectangle enclosing both the letters.
  • Next to A is M and next to D is C.
  • Similarly, E and M are neither in the same row nor a column, so we draw a rectangle enclosing both the letters.
  • Replace E and M with A and R.
  • So, with Y and X, we form a rectangle enclosing both the letters and replace Y with C and X with Q.

RELATED TAGS

network security
communitycreator
play fair
RELATED COURSES

View all Courses

Keep Exploring