EncryptedDecrypted Solution



INTRODUCTION
I need a program that we will call, ‘The CaesarCipher’ whichis abasic encryption algorithm.
Taking eachletterinthe plaintextandreplacingit with anotherletter thatis foundinthe alphabet thatis some fixednumber of positions downfromit.

(For example:intheencryption process,aCaesarcipher with a
Shiftof3willreplace alloccurrences ofthe letter‘a’ withtheletter‘d’
o all occurrences ofthe letter‘b’ withtheletter‘e’,etc.

Decryption followsthe reverse process where forashiftof 3,every letter‘d’is replacedwith the letter ‘a’,every letter‘e’ is replacedwith a‘b’.Here are some example shifts:

SHIFTOF3:

ABCDEFGHIJKLMNOPQRSTUVWXYZ
|||||||||||||||||||||||||| DEFGHIJKLMNOPQRSTUVWXYZABC


SHIFTOF23:


ABCDEFGHIJKLMNOPQRSTUV WXYZ
|||||||||||||||||||||||||| XYZABCDEFGHIJKLMNOPQRSTUVW





















PROGRAMREQUIREMENTS


BASICFUNCTIONALITY

Need a file called FileUtilitiesthatis usedencrypt and decrypt the informationinatextfile.
TheFileUtilitiesprogramshouldaccept 4command linearguments:
 anencryptor decryptcommandtoindicate whetherthe file should be encryptedor decrypted(required)
 aninteger value thatspecifies the shift (required)
 the name ofthe textfile thatis to be encryptedor decrypted(required)

The following tablelists examples thatshowhowtoinvoke the FileUtilities
programfromthe command line:
Example Invocation Description
java FileUtilities encrypt 3 secret.txt  Reads in the content of the file secret.txt.
 Encrypts the data.
 Writes the encrypted.
java FileUtilites decrypt 3 secret.txt  Reads in the contents of the file secret.txt.
 Decrypts the data.
 Writes the decrypted data back to
java FileUtilities encrypt 3 secret.txt – verbose  Prints the file contents to the console before and after encryption.



Whenthe programcompletes,amessage should be displayedtothe user indicating thatthe file has beenencryptedor decrypted like this:

C:\java FileUtilities encrypt 3 secret.txt
Fileencryptioncomplete.



C:\java FileUtilities decrypt 3 secret.txt
Filedecryptioncomplete.



ERRORHANDLING

Shouldallcheckedexceptions anddisplay an informative error message ifone occurs.The enduserof your programshouldnot see astacktrace if anexception occurs. Your programverify thatallthe required commandline arguments have beenentered,and ifarequiredinputvalueis not

provided, the programshouldissue ausage statementtohelpthe user.Here are some example scenarios with invalidinputthat your programshould handle:




Invalidcommand


C:\java FileUtilitiesbadcommand 3 secret.txt


Unrecognizedcommand:badcommand
Usage:javaFileUtilitiescommandshiftfilename[-verbose]


Invalidshift


C:\java FileUtilities encrypt three secret.txt


Unrecognizedshift:three
Usage:javaFileUtilitiescommandshiftfilename[-verbose]


FileNotFound


C:\java FileUtilities encrypt 3 doesnotexist.txt


FileNotFound:doesnotexist.txt

CODEDESIGN

Nolimitinwritingjust a single class.

Main onlyrequirement is thatthe class FileUtilities is implementedthatincludes a
1. main method and
2. supports the command line argumentsdescribed above.


TESTING



Make sure that your programhandles the followingscenarios:

1.Shiftvalues that arepositive from0 - 25
2.Shiftvalues that arenegative (try asmallone like -3)
3.Shiftvalues that arelarger than 26
4.Files thatinclude textwith non-alpha characters andmixedcase (upper and lowercase).
5.File name foranon-existentfile

WHATTOTURN IN
You shouldturninonlythe javasource filesthat are neededto runyour program. These Javasource files should beincludedatthe toplevelofaziparchive file named Project03.zip.
Powered by