Question: You will be writing a program to perform a simple encryption and decryption of a file using the Queue that you just built. Download and

You will be writing a program to perform a simple encryption and decryption of a file using the Queue that you just built. Download and extract "EncryptionAssignment.zip" from under Session 9 under Modules. You can use the logic in "Codes.java" as a starting point for your program. In order to use Codes.java, you must have the .java files necessary to run your Queue in the same folder.
Take some time to look at "textToEncode.txt"; you will be encoding the contents of this file using the keys from "key.txt". In order to keep things simple, I have included only uppercase characters in the textToEncode.txt file. You are free to change the contents of textToEncode.txt and key.txt but please make sure that the text in textToEncode.txt is all uppercase and the values in key.txt are between 1 and 10.
This assignment will build on the concept of repeating key from the slides. The first line from key.txt will be used to encode/decode the first line from textToEncode.txt/textToDecode.txt. The second line from key.txt will be used to encode/decode the second line from textToEncode.txt/textToDecode.txt and so on. Once you have use the final line from key.txt, you will go back to using the first line.
Create a new Java file "SuperCodes.java" and do the following in it:
Write a method to encode the text in file "textToEncode.txt" making use of the Queue that your have just created and output the encoded text to the screen.
Create another method to decode the text in "textToDecode.txt" in a similar manner.
Create a main() method that will use the two methods from #1 and #2
Testing: If you have edited "key.txt", "textToEncode.txt", or "textToDecode.txt", change the file contents back to the original form to check the output below.
Once your method encodes the text in "textToEncode.txt", it should output the following:
MQOTX$RTc#I[I*^[X(MSSSS#\XHK^K
K#GT+PQLTN+RKQK
\JEZ&LY%ISOTJ&TPC
KP^$KX#UOI"\HB[LGW#JU$CQDTRE"YREH]A
KY$KX$XJV[%GJNPN^%#
ITXVSIM#Q\$XNOH(JRN%cDZV$^MUV(]MWJ,RN)XRJ,\MJV8
ZZ,K#NLL^#
^DBHE[
Once your method decodes the text in "textToDecode.txt", it should output the following:
BLOW, BLOW, THOU WINTER WIND
THOU ART NOT SO UNKIND
AS MAN'S INGRATITUDE;
THY TOOTH IS NOT SO KEEN,
BECAUSE THOU ART NOT SEEN,
ALTHOUGH THY BREATH BE RUDE.
HEIGH-HO! SING, HEIGH-HO! UNTO THE GREEN HOLLY:
MOST FREINDSHIP IF FEIGNING, MOST LOVING MERE FOLLY:
THEN HEIGH-HO, THE HOLLY!
THIS LIFE IS MOST JOLLY.
-----
textToEncode.txt
HELLO HOW ARE YOU DOING TODAY?
I AM DOING FINE
WHAT IS GOING ON?
HOW IS THE WEATHER IN ALASKA TODAY?
IT IS VERY CHILLY!!
FLORIDA IS NICE AND WARM THIS TIME OF THE YEAR.
SO I HEAR!
YAAAAY
-------
textToDecode.txt
GXR_5$LQ[Z4)XRTa#_RR^J^#_RRN
VKU\+MTW&UZ`"VU'`ZMLTK
FU$SGQ-X"MTMUGYKX[JHA
WI`$VTRUO$KX#OVX"XR!RIGS/
DJGCZWG%XJTY"FVV%RQY$UJIP1
FXWPXYQM,WPb$LWQD\Q$LJ,U]MI8
MGMMN0NT#$YOQM1"LKOJN2JS'&XTYQ$ZNH<IKT#NTNP_@
NVWV%ISLMPIVIPT"NI!MIKLQJUK.%PPZX"QRWPRI%PFYI"KRMS]<
XJJR"MIKLL/MS.%XJJ$JTPN^%
YTL[)PSKQ#Q\$WT_W(SSVQe1
---------
key.txt
5,12,3,8,9,4,10
2,3,6,7,11,12
5,2,4,6,6,3,6
3,1,7,4,2,5
2,5,4
-------

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 Programming Questions!