Question
Caesar Cipher JavaProject. I have functionally made the menu, I just need some help implementing the other methods and getting it to correctly function using
Caesar Cipher JavaProject.
I have functionally made the menu, I just need some help implementing the other methods and getting it to correctly function using the filereader. Help please!
Project 3: Caesar Cipher
A Caesar cipher is a type of rotation cipher, which is a classical way to encode data. The basic idea is that there is an integer key k, and each character in a file is replaced with the character that is k digits away from it. For example, if the key is 5 and the text file begins with A then the first character in the encrypted file will be E because E is five characters away from A. This type of encryption is not actually secure among other problems, it is susceptible to frequency analysis attacks. In fact, rotation ciphers are often used as puzzles for people to solve.
Your goal for this project is to write a program that encrypts and decrypts text files using a Caesar cipher. Your program should contain the following methods with these precise signatures:
public static int getMenuOption()
This program should display a menu with the following options to the user:
1. Encrypt
2. Decrypt
3. Quit
What would you like to do?
The method should read in the users option, verify that it is valid (i.e. that it is either 1, 2 or 3) and then return that option. If the user enters an invalid option, the method should display an error message to the user andreprompt them until a valid option is entered.
public static void encrypt(File inputFile, int key)
This method should accept a text file and key as input and create an encrypted file using the supplied key and the Caesar cipher. Your program should only encrypt files with a .txt extension. The corresponding encrypted file should have the same filename, but the txt extension should be replaced with an enc extension. For example, if the input file is called myTest.txt then the output file would be called myTest.enc. If the user tries to encrypt a file that does not have a txt extension, then your program should display an error message and redisplay the menu.
public static void decrypt(File inputFile, int key)
This method should accept an encrypted file and key as input and create a decrypted file using the supplied key and the Caesar cipher. Your program should only decrypt files with a .enc extension. The corresponding decrypted file should have the same filename, but the enc extension should be replaced with a txt extension. For example, if the input file is called myTest.enc then the output file would be called myTest.txt. If the user tries to decrypt a file that does not have an enc extension, then your program should display an error message and redisplay the menu.
Your program should have any other methods you feel are necessary for it to operate correctly. Your main method should not do anything significant by itself it should only be a series of method calls with minimal control flow statements (if, switch, or loop constructs) around them.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started