Computer and Cibersecurity Project Report

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 16

Green University of Bangladesh

Department of Computer Science and Engineering (CSE)


Semester: (Spring, Year: 2023), B.Sc. in CSE (Day)

Playfair And Vigenere Ciphers

Course Title: Computer and Cyber Security


Course Code: CSE 323
Section: 202 D1
Students Details
Name ID
Mohammad Ali 202002066
Shourav Podder 202002048

Submission Date: 15/05/2023


Course Teacher’s Name: Mr. Palash Roy

[For teachers use only: Don’t write anything inside this box]

Lab Project Status

Marks: Signature:

Comments: Date:
Contents

1 Introduction 2

2 Objective 3

3 Solution Methodology 4
3.1 Playfair Cipher: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
3.2 Vigenere Cipher: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

4 Output 9

5 Learning and Difficulties 13

6 Conclusion 15

1
Chapter 1

Introduction

The Playfair Cipher is a cryptographic technique that operates on pairs of letters, also
known as digraphs, instead of individual letters. It was invented by Charles Wheatstone
in 1854 and was later promoted by Lyon Playfair, hence its name. The Playfair Cipher
provides a simple yet effective way of encrypting and decrypting messages. The en-
cryption process in the Playfair Cipher involves creating a 5x5 matrix, also known as
the Playfair square or table, which is filled with a keyword and the remaining letters of
the alphabet (excluding ’J’). The matrix is generated based on the provided key. Each
letter can only appear once in the matrix, and the letters are arranged in a specific order.

The Vigenere Cipher is a polyalphabetic substitution cipher that was invented by


Giovan Battista Bellaso in the 16th century. It is an extension of the Caesar Cipher and
provides a stronger encryption method by introducing multiple cipher alphabets. In the
Vigenere Cipher, a keyword is used to encrypt and decrypt the plaintext. The keyword
is repeated until it matches the length of the plaintext. Each letter of the plaintext is
then shifted based on the corresponding letter in the keyword. This creates a series of
different Caesar ciphers, where each letter of the keyword determines the amount of
shifting for the corresponding letter in the plaintext.
Both the Playfair and Vigenere ciphers have been historically significant and have
contributed to the development of modern encryption techniques. While the Playfair
Cipher operates on digraphs, the Vigenere Cipher extends the Caesar Cipher to cre-
ate multiple cipher alphabets, offering increased security compared to monoalphabetic
ciphers.

2
Chapter 2

Objective

The main objectives for implementing the Playfair and Vigenere ciphers can include:

• Confidentiality: Both ciphers aim to provide confidentiality by encrypting plain-


text messages, making them unreadable to unauthorized individuals. The en-
crypted ciphertext can only be deciphered using the correct key or decryption
algorithm, ensuring that the message remains confidential.

• Historical Interest: The Playfair and Vigenere ciphers have a rich historical sig-
nificance in the field of cryptography. By implementing these ciphers, you can
gain a deeper understanding of classical encryption techniques and appreciate the
evolution of cryptography over time.

• Education and Learning: Implementing these ciphers can serve as an educa-


tional exercise to explore various encryption algorithms, their principles, and their
strengths and weaknesses. It allows you to understand the underlying mecha-
nisms behind these ciphers and their cryptographic operations.

• Building Custom Encryption Tools: Implementing these ciphers can be a stepping


stone towards building custom encryption tools or libraries. Understanding the
mechanics of the Playfair and Vigenere ciphers can help us develop more com-
plex encryption systems or contribute to the development of encryption-related
applications or projects.

3
Chapter 3

Solution Methodology

The step-by-step design philosophy for the Playfair cipher and Vigenere cipher algo-
rithms are:

3.1 Playfair Cipher:


• Step 1: Generate the Playfair key table:
1.Start by removing any duplicate characters from the given key. 2.Append the
remaining unique characters of the key to the key table in order. 3.Fill the remain-
ing cells of the key table with the remaining alphabet letters in order, excluding
’J’.

• Step 2: Prepare the plaintext:


1.Remove any non-alphabetic characters from the plaintext. 2.Replace any oc-
currence of ’J’ with ’I’ in the plaintext. 3.Break the plaintext into pairs of letters,
grouping them together. 4.If the last group contains only one letter, add an ’X’ to
make it a pair.

• Step 3: Encrypt the plaintext:


1.For each pair of letters in the plaintext: 2.If the letters are in the same row, re-
place each letter with the letter to its right (wrapping around if necessary). 3.If the
letters are in the same column, replace each letter with the letter below it (wrap-
ping around if necessary). 4.If the letters are neither in the same row nor the same
column, form a rectangle using the two letters and replace each letter with the
letter at the opposite corner of the rectangle. 5.Output the encrypted ciphertext.

4
• Step 4: Decrypt the ciphertext (if needed):
1.Use the same key table generated in Step 2.Apply the reverse transformation of
the encryption process to decrypt the ciphertext.

5
3.Output the decrypted plaintext.

3.2 Vigenere Cipher:


• Step 1: Prepare the key:
1. Remove any non-alphabetic characters from the key. 2. If the key is shorter
than the plaintext, repeat the key until it matches the length of the plaintext.

• Step 2: Prepare the plaintext:


1.Remove any non-alphabetic characters from the plaintext.

• Step 3: Encrypt the plaintext:


1.For each letter in the plaintext, find the corresponding letter in the key. 2.Shift
the plaintext letter by the index of the key letter (A=0, B=1, etc.) to obtain the
ciphertext letter. 3.Wrap around the alphabet if necessary. 4.Output the encrypted
ciphertext.

6
• Step 4: Decrypt the ciphertext (if needed):
1.Use the same key. 2.Apply the reverse transformation of the encryption process
to decrypt the ciphertext.

3.Output the decrypted plaintext.

7
8
Chapter 4

Output

This figure represent all the possible feature options of this website which is basi-
cally design for cipher calculation.

9
This figure represent encription and decription of Playfair cipher. It calcute accu-
rately this output.

10
This figure represent encription and decription of Vigenere cipher. It calcute accurately
this output.

11
It show the working of reset button. When we click the reset button then it clear the pre-
vious data.

12
Chapter 5

Learning and Difficulties

During the implementation of the Playfair and Vigenère ciphers, I gained valuable in-
sights and encountered a few challenges. Here’s a summary of my learning and the
major difficulties I faced:

• Learnings:

– Cryptography Concepts: I deepened my understanding of classical encryp-


tion techniques by studying the Playfair and Vigenère ciphers. I learned
about their principles, advantages, and limitations.
– Encryption Algorithms: I familiarized myself with the step-by-step pro-
cesses of the Playfair and Vigenère ciphers, including key generation, plain-
text preparation, encryption, and decryption.
– Code Implementation: By working on the provided code, I enhanced my
programming skills and gained practical experience in implementing cryp-
tographic algorithms in a programming language.

• Difficulties:

– Key Generation: One challenge was implementing the Playfair key table
generation algorithm. Removing duplicate characters from the key and ar-
ranging the remaining characters in a specific order required careful han-
dling.
– Letter Substitution: In both ciphers, substituting letters based on their posi-
tions in the key table or using a Vigenère key proved to be a complex task.
Ensuring correct wrapping around the table/columns and handling special
cases required meticulous coding.
– Error Handling: Dealing with input validation and error handling posed
some difficulties. Handling non-alphabetic characters, replacing ’J’ with ’I’
in the Playfair cipher, and ensuring proper grouping of letters added com-
plexity to the implementation.
– Testing and Validation: Ensuring the accuracy and correctness of the en-
cryption and decryption processes was crucial. Thorough testing with dif-
ferent input scenarios and validating the results against expected outputs
demanded careful attention to detail.

13
Overall, the implementation of the Playfair and Vigenere ciphers provided valuable
learning opportunities and challenged me to overcome difficulties related to key gener-
ation, letter substitution, error handling, and testing. By addressing these challenges, I
enhanced my understanding of classical encryption techniques and improved my coding
skills in the field of cryptography.

14
Chapter 6

Conclusion

In this project, we implemented two classical encryption techniques: the Playfair ci-
pher and the Vigenere cipher. The objective was to gain a deeper understanding of
these ciphers and enhance our coding skills in the field of cryptography. Throughout
the project, we learned about the fundamental principles and processes of the Playfair
and Vigenere ciphers. We explored key generation, plaintext preparation, encryption,
and decryption steps for both ciphers. By implementing these algorithms, we gained
practical experience in coding cryptographic techniques and developed a clearer under-
standing of their advantages and limitations. The project also presented some challenges
that helped us refine our problem-solving skills. Generating the Playfair key table re-
quired careful handling of duplicate characters and arranging the remaining characters
in a specific order. Substituting letters based on their positions in the key table or using
a Vigenere key demanded precise coding to ensure correct wrapping and handling of
special cases. We also faced difficulties in handling non-alphabetic characters, replac-
ing ’J’ with ’I’ in the Playfair cipher, and ensuring proper grouping of letters. Error
handling and testing were crucial aspects of the project, as we had to validate the accu-
racy and correctness of the encryption and decryption processes. Overall, this project
provided a comprehensive learning experience in classical encryption techniques and
their implementation. It allowed us to deepen our understanding of cryptography con-
cepts, enhance our programming skills, and gain practical insights into the challenges
involved in coding cryptographic algorithms. By successfully implementing the Play-
fair and Vigenere ciphers, we have laid a solid foundation for further exploration in the
field of cryptography. This project serves as a stepping stone towards more advanced
encryption techniques and modern cryptographic algorithms.

15

You might also like