Cyber Security Lab Assignment 6
Cyber Security Lab Assignment 6
A. Caesar Cipher
1. Implement the Caesar Cipher
import java.util.Scanner;
int key;
try {
key = sc.nextInt();
} catch (Exception e) {
System.out.println("Invalid key! Must be an integer.");
return;
}
while (true) {
System.out.println("1. Encrypt\n2. Decrypt\n3. Exit...");
int choice = sc.nextInt();
switch (choice) {
case 1:
System.out.println("Encrypted message: " + encrypt(str, key));
break;
case 2:
System.out.println("Decrypted message: " + decrypt(encrypt(str, key), key));
break;
case 3:
System.exit(0);
break;
default:
System.out.println("Invalid option..");
}
}
}
class DiffieHellman {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
class ModifiedDiffieHellman {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
These implementations strictly follow your provided notes and structure. Let me know if you
need any modifications or clarifications.