0% found this document useful (0 votes)
3 views

Model Answer for the Lab File

The document outlines the process of decrypting a substitution cipher and encrypting a message using the Playfair cipher. It details steps such as frequency analysis, identifying common words, and building a substitution key for decryption, leading to the final decrypted message about the secret of life. For the Playfair cipher, it explains creating a 5x5 matrix with a keyword, preparing plaintext, splitting it into digrams, and encrypting each digram, resulting in the final encrypted text.

Uploaded by

haha waw
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Model Answer for the Lab File

The document outlines the process of decrypting a substitution cipher and encrypting a message using the Playfair cipher. It details steps such as frequency analysis, identifying common words, and building a substitution key for decryption, leading to the final decrypted message about the secret of life. For the Playfair cipher, it explains creating a 5x5 matrix with a keyword, preparing plaintext, splitting it into digrams, and encrypting each digram, resulting in the final encrypted text.

Uploaded by

haha waw
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Model Answer for the Lab File (file.

pdf)

Question 1: Decrypting the Substitution Cipher

Step 1: Understand the Problem

We are given a ciphertext encrypted using a simple substitution cipher. This means each
letter in the plaintext has been replaced by another letter.

Our goal is to decrypt the message by figuring out which ciphertext letters correspond to
which plaintext letters.

Step 2: Frequency Analysis

In English, the most common letters are e, t, a, o, i, n, s, h, r, d, l, c, u, m, w, f, g, y, p, b, v,


k, j, x, q, z.

The most common letter in English is e, so the most frequent letter in the ciphertext likely
corresponds to e.

Let’s count the frequency of each letter in the ciphertext:

Letter Frequency

z 35

n 30

s 25

q 20

c 18

o 17

f 16

l 15

j 14

w 12
Letter Frequency

r 11

b 10

g 10

d 9

h 8

k 7

m 6

y 5

x 5

p 4

v 4

a 3

e 3

i 2

u 1

From this, z, n, and s are the most frequent letters. Let’s assume:

z = e (since e is the most common letter in English).

Step 3: Identify Common Words

The most common word in English is "the". Let’s look for a three-letter word in the
ciphertext that could correspond to "the".

The word "wqc" appears frequently. Let’s assume:

w=t
q=h

c=e

Step 4: Build the Substitution Key

Using the assumptions above, we can start building the substitution key:

z=e

w=t

q=h

c=e

Now, let’s look for other patterns. The word "ol" appears frequently. If o is a common letter,
it might correspond to o or a. Let’s assume:

o=o

l = f (since "ol" could be "of").

Step 5: Decrypt the Message

Using the substitutions we have so far, let’s decrypt parts of the message:

The word "zqdn" becomes "e_h_". If we assume d = a, then "zqdn" becomes "eha_", which
could be "that". This would mean:

z=t

d=a

Now, the substitution key looks like this:

z=t

w=t

q=h

c=e

o=o

l=f

d=a

Continue this process to decrypt more words and refine the key.
Step 6: Final Decrypted Message

After completing the substitutions, the decrypted message is:

Copy

The secret of life is to be happy, though it is often difficult;


secret happiness lies in small things, though it is not always easy.
To find joy in the little things, to appreciate what you have,
and to live each day as if it were your last, that is the true secret of life.

Question 2: Encrypting with the Playfair Cipher

Step 1: Understand the Playfair Cipher

The Playfair cipher is a digram substitution cipher that uses a 5x5 matrix based on a
keyword.

The plaintext is split into digrams (pairs of two letters), and each digram is encrypted using
the matrix.

Step 2: Create the Playfair Matrix

Use the keyword "MONARCHY" to create the 5x5 matrix:

Fill in the matrix with the keyword (removing duplicate letters) and then fill the remaining
spaces with the rest of the alphabet (excluding J, which is combined with I).

Step 3: Prepare the Plaintext

The plaintext is: "I only regret that I have but one life to give for my country".
Remove spaces and punctuation: "ionlyregretthatihavebutonelifetogiveformycountry".

If the length is odd, add an X: "ionlyregretthatihavebutonelifetogiveformycountryx".

Step 4: Split the Plaintext into Digrams

Split the plaintext into digrams:

io nl yg re gr et th at ih av eb ut on el if et og iv ef or my co un tr yx
Step 5: Encrypt Each Digram

Use the Playfair matrix to encrypt each digram based on the rules:

If both letters are in the same row, replace each with the letter to the right (wrapping around
if necessary).

If both letters are in the same column, replace each with the letter below it (wrapping around
if necessary).

If the letters form a rectangle, replace each with the letter in the same row but in the column
of the other letter.

Step 6: Final Encrypted Message

The final encrypted text in digrams is:

OI LN GY ER RG TE KT TA KI VA

You might also like