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 encryptiondecryption 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,
Name:
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 filedoc into the output cipher file named
filecrp using the key string xtEvfyo for example, assuming that we
already have the file called filedoc we would write the following command:
Prompt java ProgName enc filedoc filecrp xtEvfyo
b To convert the cipher file named filecrp back into the corresponding original
file named filepdf using the key string uhgrvf for example, assuming
that we already have the file called filecrp we would write the following
command:
Prompt java ProgName dec filecrp filepdf uhgrvf
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 Base coders and a simple permuted character
substitution cipher, where:
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
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.
When encrypting, the program shall read the input file as binary bytes and use a
Base encoder to convert them to ASCII characters that can be encrypted as in step
below. See: java.util.Base for how to use the Base coding.
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 below,
and then use a Base decoder to convert them back to the original bytes.
EE Project # Due: February
Name:
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 HNN
For decryption, use: L
N LHNN
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:
If the number of parameters is less than it should print an error message and exit.
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.
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.
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.
Read the fourth parameter. This is the key string used to calculate H and the locations
L
of the replacement characters in S
Do the required conversions as described before.
When the end of input file is reached, close all files, print a success message and exit.
Important: Test your program thoroughly both ways.
Note
Your conversion character array, S must include ALL the alphanumeric and punctuation characters from the English ASCII table. ie All those characters you can see
in your English keyboardASCII to
While testing your program, try to decrypt the given crypt file using the key Hello
EE Project # Due: February
Name:
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 strings 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
