From 81ba9eb66f8284d8760012973f84cdbe617ceb94 Mon Sep 17 00:00:00 2001 From: pants Date: Mon, 21 Sep 2026 14:16:34 -0700 Subject: init --- ciphers/Client.java | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 ciphers/Client.java (limited to 'ciphers/Client.java') diff --git a/ciphers/Client.java b/ciphers/Client.java new file mode 100644 index 0000000..fb87354 --- /dev/null +++ b/ciphers/Client.java @@ -0,0 +1,45 @@ +import java.util.*; +import java.io.*; + +public class Client { + // TODO: Change this line once you've implemented a cipher! + public static final Cipher CHOSEN_CIPHER = null; + + // (we also encourage you to change Cipher.MIN_CHAR and Cipher.MAX_CHAR when testing!) + public static void main(String[] args) throws FileNotFoundException { + Scanner console = new Scanner(System.in); + System.out.println("Welcome to the CSE 123 cryptography application!"); + System.out.println("What would you like to do?"); + int chosen = -1; + do { + System.out.println(); + System.out.println("(1) Encode / (2) Decode a string"); + System.out.println("(3) Encode / (4) Decode a file"); + System.out.println("(5) Quit"); + System.out.print("Enter your choice here: "); + + chosen = Integer.parseInt(console.nextLine()); + while (chosen < 1 || chosen > 5) { + System.out.print("Please enter a valid option from above: "); + chosen = Integer.parseInt(console.nextLine()); + } + + if (chosen == 1 || chosen == 2) { + System.out.println("Please enter the string you'd like to " + + (chosen == 1 ? "encode" : "decode") + ": "); + String input = console.nextLine(); + System.out.println(chosen == 1 ? CHOSEN_CIPHER.encrypt(input) : + CHOSEN_CIPHER.decrypt(input)); + } else if (chosen == 3 || chosen == 4) { + System.out.print("Please enter the name of the file you'd like to " + + (chosen == 3 ? "encode" : "decode") + ": "); + String fileName = console.nextLine(); + if (chosen == 3) { + CHOSEN_CIPHER.encryptFile(fileName); + } else { + CHOSEN_CIPHER.decryptFile(fileName); + } + } + } while (chosen != 5); + } +} -- cgit v1.2.3