Prog 4: CryptoFile

3/2 Additional explanation added on 3/2, shown in green. Specific filenames are now required.

3/8 Changed which files are used, both for cipher.txt as well as changed huck.txt to lifeonmiss.txt.  These changes shown highlighted in red.  Your decoding with this combination will work much better, except characters F,G and J,X will still be mixed up. I have provided sample output below with these particular files, so you can check your work.  I added an extra credit option, and extended the deadline by 3 days.

The cipher.txt file has been encrypted by doing letter substitution.  In other words, every time a particular letter occurred in the entire file (upper or lower case), a different character was substituted for it instead.  Spaces and punctuation were left alone, only modifying the alphabetic characters.  (See this sample program to illustrate how to count characters from an input file.)  

Write a program to 

Running the program to encode should look like:

    Author: Dale Reed      Program #4: CryptoFile      TA: Elliott Ness, T 6:00 AM      Feb 26, 2016      System: XCode on Mac       Choose your option:      1. Encrypt a file      2. Decrypt a file      Your choice: 1      You entered option 1 to encrypt file sample.txt      The first part of that encrypted file looks like:                  The encrypted file is:      Zhu Wdmsuiz Vxzuaeudv UEmmn mt Zhu Zdkvujo mt Wxjj'ahukj Bpcqma, eo      Fkdn Zbkpa (Qkfxuc Icufuaq)            Zhpq uEmmn pq tmd zhu xqu mt kaomau kaobhudu kz am imqz kaj bpzh      kcfmqz am duqzdpizpmaq bhkzqmuyud.  Omx fko imwo pz, vpyu pz kbko md      du-xqu pz xajud zhu zudfq mt zhu Wdmsuiz Vxzuaeudv Cpiuaqu paicxjuj      bpzh zhpq uEmmn md macpau kz bbb.vxzuaeudv.mdv      . . .

Running the program to decode should look like:

    Author: Dale Reed      Program #4: CryptoFile      TA: Elliott Ness, T 6:00 AM      Feb 26, 2016      System: XCode on Mac            Choose your option:      1. Encrypt a file      2. Decrypt a file      Your choice: 2      You entered option 2 to decrypt file  cipher.txt  using  lifeonmiss.txt  for frequency counts.      The first part of that decrypted file looks like:          The Proxect Futenberf EBook og The Trafedy og Pudd'nhead Wilson, by      Mark Twain (Samuel Clemens)            This eBook is gor the use og anyone anywhere at no cost and with      almost no restrictions whatsoever.  You may copy it, five it away or      re-use it under the terms og the Proxect Futenberf License included      with this eBook or online at www.futenberf.orf      . . .

To read a single character at a time, including reading spaces, in a C++ program you should use cin.get( c) where c was previously declared as a char variable. If you are instead reading from an input file stream called (for instance) inStream, then you would use inStream.get( c).

Turning In Your Program

Failing to follow these naming conventions and failure to turn in a single zip file will result in a 5 point deduction, even if everything else is perfect in your program.

Extra Credit:

(10 points additional) After figuring out the substitution array to decrypt your file, go through all pairs of adjacent letters, swapping them to see if more resulting words are found in the dictionary with that swap.  Let the final file version be the one with swaps included that give the best possible result.  For example in the sample output shown above, the pairs (F,G)  and (J,X) weren't figured out correctly and should be swapped.  Your program would have to figure that out automatically.  Extra Credit programs may not be turned in late. Turn this in to Blackboard into the Program4: Extra Credit assignment.