Assignment[1]
Assignment[1]
Assignment #1
Student Name:
Rida Zahra 465791
Mawa Ch 474121
Tazeen ur Rehman 466342
Degree/ Syndicate: CE 45 A
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).
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