Question: What do you have to do ? You are given a number of files to use as outlined below: - PublicKeyEncryption.java: This is a complete
What do you have to do
You are given a number of files to use as outlined below:
PublicKeyEncryption.java: This is a complete class that you cannot modify. It contains the
basics to use Asymmetric Key Encryption.
SimpleAsymKeyEncryptApp.java: This is mostly a complete class. You will need to add
code and modify existing code as outlined below in steps
MasterPrivateKey.key: This is a private key that was generated along with its public key
equivalent. The public key was used to encrypted the next file...
Encrypted.bin: This file contains encrypted text. The key in the file MasterPrivateKey.key
will decrypt it
Changed you need to implement:
Convert the for loop in private static String getTextFileAsString method to a while loop. Make
sure to comment the method as well.
Surround the long ifelse structure in main method with a dowhile loop, such that the program
will only end when the user enters in the value as a choice.
Convert the long ifelse structure to a switchcase Also take care of the scenario where the user
does not enter a valid choice Tell them they made an invalid choice. Hint: look up the
default keyword.
For choices through 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.
Change choice 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!
Test the program. Create a text file either with notepad or Eclipse and put a message in it less
than characters Run the program, choose and encrypt the text file.
Immediately choose See if the decrypted text file matches the original text files message.
Choose options and to save the current pair of public and private keys to text files.
Choose to quit.
Rerun the program.
Use the private key provided to you MasterPrivateKey.key on myCourses with choice 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.
Rerun the program again a few times, choosing option to encrypt a new text file with varying
amounts of text. Be sure to save the encrypted files with different names.
Answer the following questions in the comments at the top of your code
SimpleAsymKeyEncryptAppjava
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
d If we cant go above characters to encrypt, but we have more than 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?
Done? Demonstrate the program to the TA Be sure to show the decrypted message from step
as well.
Submit the following files to myCourses.
a PublicKeyEncryption.java
b SimpleAsymKeyEncryption.java
c The text file you created with some message in step
d The encrypted file created by the program in step
e The private key file from step
f The public key file from step import java.util.;
import java.io;
import java.security.;
public class SimpleAsymKeyEncryptApp
public static void mainString args
Other implementations other than RSA do not work without messing with Eclipse's settings
PublicKeyEncryption pke new PublicKeyEncryptionPublicKeyEncryptionAlgorithmTypes.RSA;
Keyboard input.
Scanner kbInput new ScannerSystemin;
Used to get the users choice from the
int choice;
String bufferData;
byte encryptedData decryptedData;
PublicKey publicK;
PrivateKey privateK;
System.out.println;
System.out.printlnWelcome to the Simple Asymmetric Key Encryption Program";
System.out.println;
System.out.printlnPlease choose from the following options:";
System.out.println Save my public key to a binary file.";
System.out.println Save my private key to a binary file.";
System.out.println Generate a new set of my keys.";
System.out.println Encrypt using my key";
System.out.println Decrypt using my key";
System.out.println Encrypt using a key from a file";
System.out.println Decrypt using a key from a file";
System.out.println Quit the program
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
