Question: Please answer in Java :) ~ PART 1 ~ You should create a program called Encyrpt.java which will contain the following specified method. One of

Please answer in Java :)

~ PART 1 ~

You should create a program called Encyrpt.java which will contain the following specified method.

One of the simplest encryption techniques is to substitute each character in the message with a corresponding character (position with relations to a) from a substitution keypad that re-orders the alphabet in some fashion. To that end, you must provide a method genKeyPad that will generate a completely random ordering of all lower case characters (different each time you run it) as a string. For example, calling this method might return:

"gphijonmqdefrxyzklstuvabcw"

The signature for this method will be:

public static String genKeyPad()

Write a method encryptLine that will take a line of text and encrypt it using a randomly generated keypad as described above (substituting each lower case character with the corresponding character from the keypad. The method signature for this will be:

public static String encryptLine(String sPlainText, String sKeypad)

The main method of this program should take in the name of file to be encrypted as a command line argument. If and if only the given text file has a txt suffix, then proceed to encrypt the entire file using the encrypt method for each of the lines in the file. Numbers and punctuation should be written through to the encrypted file. All upper-case letters are converted to lower case before being encrypted. The keypad string will be recorded in a file called enc.txt. You are going to be overwriting the original file will the encrypted file. If the indicated file does not exist or is not a .txt file than exist with appropriate error message and program status code of 1.

~ PART 2 ~

Write a separate program Decrypt.java which takes in the name of an encrypted file as a command line argumet and the name of a file containing an appropriate keypad string. This program will proceed to decrypt that file using the given keypad. This program is the reverse of the previous program and if you ran these 2 programs in sequence you should wind up with the original file (with all uppercase letters being replaced by lower case letters). As before if the given encrypted file or the keypad file does not exist then exit with an error code of 1 and appropriate error message.

Thanks in advance for any help!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!