PLAYFAIR - CIPHER and Huffmann Coding

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 34

Go, change the world

RV College of
Engineering

TOPIC: PLAYFAIR CIPHER

DOMAIN: CYBERSECURITY AND


CRYPTOGRAPHY

ADHITYAA CCHENJI - 1RV20EC007


DHRUV SRIVASTAVA - 1RV20EC058
RAHUL CHANDRA - 1RV20EC121
RV College of
Engineering
Go, change the world

Objective:
• Our main objective of phase 2 is to encrypt a message/word using Play-fair cipher technique
and then compress its memory without losing any data.
• This will help us in sending compressed data, thereby reducing the amount of memory
consumed by the system.
• To implement this, we are going to use play-fair algorithm and then compress the encrypted
word using an algorithm called huff-man coding.
RV College of
Engineering
Go, change the world

What is Playfair Cipher?

1. The Playfair cipher or Playfair square or Wheatstone–Playfair cipher is a manual


symmetric encryption technique.
2. The technique encrypts pairs of letters instead of single letters as in the
simple substitution cipher .
3. The Playfair is thus significantly harder to break since the frequency analysis used for
simple substitution ciphers does not work with it.

The Playfair Cipher Was used in the First and Second World Wars because it is fast to use
and it doesn’t require any equipment.
RV College of
Engineering
Go, change the world

1. The Playfair Cipher consists of a 5 by 5 grid in which contains the keyword or the
phrase.

2. Each of the 25 alphabets must be unique and one letter of the alphabet (usually J) is
omitted from the table (as the table can hold only 25 alphabets). If the plaintext
contains J, then it is replaced by I.

3. The initial alphabets in the key square are the unique alphabets of the key in the
order in which they appear followed by the remaining letters of the alphabet in order.
4. The plaintext is split into pairs of two letters (digraphs). If there is an odd number of
letters, a Z is added to the last letter.

EXAMPLE : PlainText: "instruments"


After Split: 'in' 'st' 'ru' 'me' 'nt' 'sz‘
RV College of
Engineering
Go, change the world

Plain Text: "instrumentsz"


Encrypted Text: gatlmzclrqtx
Encryption:
i -> g
n -> a
s -> t
t -> l
r -> m
u -> z
m -> c
e -> l
n -> r
t -> q
s -> t
z -> x
RV College of
Engineering ENCRYPTION MATRIX Go, change the world
RV College of
Engineering
FLOWCHART PLAY-FAIR CIPHERGo, change the world
RV College of Introduction to Huff-mann Coding Go, change the world
Engineering

• Huffman coding is a lossless compression technique used to assign variable length codes to input
characters, length of the codes assigned is based on frequencies of the corresponding characters.
• Huffman Coding is generally useful to compress the data in which there are frequently occurring
characters
• We are going to use priority queues or heaps along with binary trees to implement this algorithm .
• Time complexity of the algorithm is O(nlogn).
RV College of
Engineering ALGORITHM FOR HUFF-MAN TECHNIQUE Go, change the world

Step 1. Build a min heap that contains 6 nodes where each node represents root of a tree with
single node.

Step 2 Extract two minimum frequency nodes from min heap. Add a new internal node with
frequency 5 + 9 = 14. 

Now min heap contains 5 nodes where 4 nodes are roots of trees with single element
each, and one heap node is root of tree with 3 elements
RV College of
Engineering ALGORITHM Go, change the world

character Frequency
c 12
d 13
Internal Node 14
e 16
f 45

Step 3: Extract two minimum frequency nodes from heap. Add a new internal node with
frequency 12 + 13 = 25
RV College of
Engineering ALGORITHM Go, change the world

Now min heap contains 4 nodes where 2 nodes are roots of trees with single element each,
and two heap nodes are root of tree with more than one nodes

Character Frequency
Internal Node 14
e 16
Internal Node 25
f 45

Step 4: Extract two minimum frequency nodes. Add a new internal node with frequency 14 +
16 = 30
RV College of
Engineering ALGORITHM Go, change the world

Now min heap contains 3 nodes.

Character Frequency
Internal Node 25
Internal Node 30
f 45

Step 5: Extract two minimum frequency nodes. Add a new internal node with
frequency 25 + 30 = 55
RV College of
Engineering ALGORITHM Go, change the world

Now min heap contains 2 nodes.

Character Frequency
f 45
Internal Node 55

Step 6: Extract two minimum frequency nodes. Add a new internal node with frequency 45 + 55
= 100
RV College of
Engineering ALGORITHM Go, change the world

Now min heap contains only one node.

Character Frequency
Internal Node 100

Since the heap contains only one node, the algorithm stops here.
COMPRESSION OF ENCRYPED CODE (PLAYFAIR-
RV College of
Go, change the world
Engineering CIPHER) USING HUFFMAN TECHNIQUE
RV College of
Engineering
Go, change the world
RV College of
Engineering
Go, change the world
RV College of
Engineering
Go, change the world
RV College of
Engineering
Go, change the world
RV College of
Engineering
Go, change the world
RV College of
Engineering
Go, change the world

.
RV College of
Engineering
Go, change the world
RV College of
Engineering
Go, change the world
RV College of Go, change the world
Engineering
RV College of
Engineering
Go, change the world
RV College of
Engineering
Go, change the world
RV College of
Engineering
Go, change the world
RV College of
Engineering
Go, change the world
RV College of
Engineering
Go, change the world
RV College of
Engineering
Go, change the world
RV College of
Engineering
Go, change the world
RV College of
Engineering
APPLICATIONS OF PLAYFAIR CIPHER Go, change the world

1. Used in communication systems to prevent data getting tapped.

2. Used to encrypt and decrypt data of DNA and biological modifications can be performed.

3. Advanced thematic cryptic crosswords like occasionally incorporate playfair ciphers. normally between four and
six answers have to be entered into the grid in code, and the playfair keyphrase is thematically significant to the
final solution.
RV College of
Go, change the world
Engineering
Applications of Huffman Coding :

1.They are used for transmitting fax and text.

2.They are used by conventional compression formats like pkzip, gzip, etc.

 3.It is useful in cases where there is a series of frequently occurring characters.


Outcomes:

• We understood different encryption techniques used in the domain if cyber security and cryptography.
• In order to learn huffmann algorithm, we had to understand basics and implementation of Binary
Trees, Linked Lists and priority queues.
• In general, it helped us in understanding basic data structures and algorithms.

You might also like