Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Convert the for loop in private static String getTextFileAsString ( ) method to a while loop. Make sure to comment the method as well. 2

Convert the for loop in private static String getTextFileAsString() method to a while loop. Make
sure to comment the method as well.
2. Surround the long if/else structure in main method with a do/while loop, such that the program
will only end when the user enters in the value 8 as a choice.
3. Convert the long if/else structure to a switch/case. Also take care of the scenario where the user
does not enter a valid choice (1-8). Tell them they made an invalid choice. Hint: look up the
default keyword.
4. For choices 1 through 7... slightly modify the code to allow the user to choose the names of the
files (instead of them being hardcoded). Hint, use an instance of Scanner to get the users
response, and store their answer in a String.
5. Change choice 7 so the decrypted text is written to a text file (of the users choice) instead of
the console (Hint: replace System.out with an instance of PrintWriter... dont forget to close it
either!)
6. Test the program. Create a text file (either with notepad or Eclipse) and put a message in it (less
than 117 characters). Run the program, choose 4 and encrypt the text file.
Immediately choose 5. See if the decrypted text file matches the original text files message.
7. Choose options 1 and 2 to save the current pair of public and private keys to text files.
8. Choose 8 to quit.
9. Rerun the program.
10. Use the private key provided to you MasterPrivateKey.key on myCourses with choice 7. Use the
file Encrypted.bin from myCourses as the encrypted file to decrypt here. The resulting file, if all
works properly, will contain a message in English.
11. Rerun the program again a few times, choosing option 4 to encrypt a new text file with varying
amounts of text. Be sure to save the encrypted files with different names.
12. Answer the following questions in the comments at the top of your code
(SimpleAsymKeyEncryptApp.java)
a. For each of the encrypted files you created, what can you note about the file size? (right
click on the file and choose properties).
b. Does it seem like the amount of text you encrypted seemed to have an impact on the
encrypted files size?
c. Does the size seem to relate to the limitation of the number of characters in the textfile
(117)?
d. If we cant go above 117 characters to encrypt, but we have more than 117 to encrypt,
what would be a simple solution to fix this? (Hint: If you have to ship a large item, but
that item is bigger than the biggest single box allowed to ship it, what can you do to the
item to ship it and make sure it all makes it there in the end?)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Manga Guide To Databases

Authors: Mana Takahashi, Shoko Azuma, Co Ltd Trend

1st Edition

1593271905, 978-1593271909

More Books

Students also viewed these Databases questions

Question

Find y'. y= |x + X (x) (x) X 1 02x+ 2x 1 O 2x + 1/3 Ex 2x +

Answered: 1 week ago

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago