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

Assignment[1]

Uploaded by

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

Assignment[1]

Uploaded by

tazeenurrehman19
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

MATH161 Discrete Mathematics

Assignment #1

"Building Your Secure Communication System"

Course Instructor: Dr Syed Tayyab Hussain

Student Name:
Rida Zahra 465791
Mawa Ch 474121
Tazeen ur Rehman 466342

Degree/ Syndicate: CE 45 A

Date: 23rd December, 2024


Objective:
To apply knowledge of Caesar Cipher and RSA algorithms in designing a secure
communication system. Students will implement encryption and decryption functionalities
for both algorithms andcreate a program that switches between them based on user input.
Algorithm should be designedto encrypt and decrypt the whole keyboard.

Task Description:
1. Generalized Caesar Cipher Implementation:

𝐹(𝑥) = 𝑎 ∗ 𝑥 + 𝑏
o Implement the Generalized Caesar cipher for both encryption and decryption

o Allow the user to specify the values of a (only those values which are invertible in
the modulo class)
o Allow the user to choose the shift key b,
o Ensure input text can handle spaces, punctuation, and mixed case sensitivity
(complete keyboard using ASCII keys).

2. RSA Algorithm Implementation:


o Write a function to:
▪ Generate two random prime numbers for key generation.
▪ Calculate n, ϕ(n), public key e, and private key d.
o Implement encryption and decryption using the generated keys.
o Provide clear prompts for the user to input messages for encryption.

3. System Integration:
o Create a menu-driven program:
▪ Option 1: Encrypt using Caesar cipher.
▪ Option 2: Decrypt using Caesar cipher.
▪ Option 3: Encrypt using RSA.
▪ Option 4: Decrypt using RSA.
o Allow the user to choose the algorithm and input text interactively.
o Save the encrypted message to a file and read it back for decryption.

4. Bonus Challenge:
o Add functionality to break the Caesar cipher without the key (using frequency
analysis).
o Write test cases to validate the correctness of RSA encryption and decryption.

Learning Outcomes:
• Understand the implementation details of Caesar Cipher and RSA algorithms.
• Differentiate between symmetric and asymmetric encryption systems.
• Practice modular arithmetic and key management in cryptography.
• Think creatively to handle real-world scenarios like breaking the Caesar cipher.
UML Diagram

Main:

Main

main(String[]): void
+ displayMenu(): void
+ handleCaesarCipher(): void
+ handleRSACipher(): void
+ testRSA(): void
+ saveToFile(message: String, fileName: String): void
+ readFromFile(fileName: String): String

CaesarCipher:

CaesarCipher
- a: int
- b: int
- modulo: int
+ CaesarCipher(a: int, b: int): void
+ encrypt(text: String): String
+ decrypt(text: String): String
+ validateA(): boolean
+ breakCipher(encryptedText: String): String

RSAAlgorithm

RSAAlgorithm
- p: int
- q: int
- n: int
- phi: int
- e: int
- d: int
+ generateKeys(): void
+ encrypt(message: String): String
+ decrypt(encryptedMessage: String): String

You might also like