Question: Write a simple encryption / decryption program that applies the idea mentioned above. The program shall read from any original ( input ) plain file

Write a simple encryption/decryption program that applies the idea mentioned above.
The program shall read from any original (input) plain file and write its corresponding encrypted version to another (output) crypt file; or does the reverse, depending on
an input parameter, where it shall read a crypt (input) file and writes its corresponding
decrypted version to an (output) plain file. Your program must get the required inputs
as command line parameters. These include:
(a) What to do; enc for encryption or dec for decryption,
(b) The input filename with its extension,
1
Name: 2
(c) The output filename with its extension, and
(d) The encryption key string any string.
The above parameters must appear in the command line in the same order as above
and as shown in the following examples:
(a) To encrypt the input file named file1.doc into the output cipher file named
file1.crp using the key string !xtEvfy123?o for example, assuming that we
already have the file called file1.doc, we would write the following command:
Prompt > java ProgName enc file1.doc file1.crp !xtEvfy123?o
(b) To convert the cipher file named file2.crp back into the corresponding original
file named file2.pdf using the key string u*hg7r43vf for example, assuming
that we already have the file called file2.crp, we would write the following
command:
Prompt > java ProgName dec file2.crp file2.pdf u*hg7r43vf
As you noticed from the above examples, ProgName is the name of your program;
and the key string can have any number of English alphanumeric and punctuation
characters.
The Encryption Algorithm
In this assignment, you are asked to use Base64 coders and a simple permuted character
substitution cipher, where:
1. At the start of the program you may define a character array S that contains all the
ASCII characters ordered according to their ASCII code values. Assume that this
array has size N.
2. The input key string shall be converted into a corresponding unique integer value H
by adding the ASCII value of each character multiplied by its position in the string.
3. When encrypting, the program shall read the input file as binary bytes and use a
Base64 encoder to convert them to ASCII characters that can be encrypted as in step
5 below. See: java.util.Base64 for how to use the Base64 coding.
4. When decrypting, the program shall do the reverse; it shall read the input file as binary bytes corresponding to encrypted characters, decrypt them as in step 5 below,
and then use a Base64 decoder to convert them back to the original bytes.
EE 367 Project #01 Due: February 03,2024
Name: 3
5. The permuted character substitution cipher works as follows: Every one of the generated ASCII characters, call it C, can be encrypted or decrypted by finding its location
L in S, then performing the following function to get L
, which is the location in S of
a character substitute C
, then C is substituted by C
before any further processing:
For encryption, use: L
=(L + H%N)%N.
For decryption, use: L
=(N + LH%N)%N.
6. Note that your program shall read and write bytes not characters
Your program shall read the command line and get all the parameters in the args string
of the main method. These strings must be processed as follows:
1. If the number of parameters is less than 4, it should print an error message and exit.
2. Read the first parameter, and check it. If it is enc, do an encryption operation. If it
is dec, do a decryption operation. Otherwise, print an error message and exit.
3. Read the second parameter and check if the input file name exists on disk. If the file
does not exist, print an error message and exit.
4. Read the third parameter and create this output file, checking for any errors. If errors
do occur, print an error message, close the input file and exit.
5. Read the fourth parameter. This is the key string used to calculate H and the locations
L
of the replacement characters in S.
6. Do the required conversions as described before.
7. When the end of input file is reached, close all files, print a success message and exit.
8. Important: Test your program thoroughly both ways.
Note
1. Your conversion character array, S, must include ALL the alphanumeric and punctuation characters from the English ASCII table. (i.e. All those characters you can see
in your English keyboardASCII 32 to 126).
2. While testing your program, try to decrypt the given crypt file using the key Hello.
EE 367 Project #01 Due: February 03,2024
Name: 4
What to turn in
Submit one .zip file containing your cover page, the fully documented and commented
.java source program, my decrypted plain file, and two more files: plain and crypt you used
for testing, along with the key string(s) used.
Remember: A broken program has no value. It gets a zero mark.
Therefore, Start Early and test thoroughly. Do not waste your allowed time.

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!