Question: *****PLEASE CODE IN C++****** The goal of this project is to break a substitution cipher. A [substitution cipher](https://en.wikipedia.org/wiki/Substitution_cipher) is a cipher in which a plaintext

*****PLEASE CODE IN C++******

The goal of this project is to break a substitution cipher. A [substitution cipher](https://en.wikipedia.org/wiki/Substitution_cipher) is a cipher in which a plaintext is converted character by character into ciphertext by using a predetermined rule of association. For example, the Caesar cipher is a special kind of substitution cipher in which

$A ightarrow D$, $B ightarrow E$, $C ightarrow F$, etc.

The Caesar cipher has a very simple form, because each character is simply advanced three places to form the ciphertext. However, in general, the rule can be more complicated.

The following text is given in the file called `ciphertext.txt` in the assignment folder.

``` Z[%csX%WZ|Zi%RRZi*RRZLaZ[Z|<%7Z%ZRP\XZWP[%sZXL*|%|ZLiZ4XPsXZX%ZsL*RWZWP|%ZLiZcZ|cPRL[ZcRLa%Z[%y%cR%WZ%|Zi%P\a%WZ|XL*RWZXc77%aZPaZ[%cRP<>Wca<|Zc|Z4%ZXcy%Z|cPWZXcWZ<[cs%WZZR%WZ+7XZZ4PW%ZcZsLas%cR%WZi[L+ZLO|%[ycZ*|%WZ[PaZZ7%[7R%6%WZ%W+LaWZcaWZW%|<[L>%WZXP|ZZXL4ZsL*RWZZ+%a|*WW%aR>ZcaZPW%cZiRc|X%WZcs[L||ZXP|Z+PaWZPa|<%cWZLiZ[cP|Pa\ZPZXcy%ZRL4%[%WZPZ|ZXcWZO%%aZsLy%[%WZ4P[

This ciphertext was produced in the following way:

1. A plaintext was chosen consisting only of uppercase alphabetical characters and the space character. 2. A mapping was chosen at random from the ASCII characters {' ','A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'} into all printable ASCII characters. 3. Each plaintext character was replaced by its image character under the mapping.

In case this is confusing, the following simplified example may be helpful. Suppose that the plaintext is "WHAT ARE YOU SAYING". We pick a rule of association that maps the plaintext characters to ciphertext characters in the following way:

$A ightarrow X$

$B ightarrow E$

$C ightarrow v$

$D ightarrow \&$

$E ightarrow r$

$F ightarrow z$

$G ightarrow @$

$H ightarrow 6$

$I ightarrow \backslash$

$J ightarrow 8$

$K ightarrow 5$

$L ightarrow e$

$M ightarrow :$

$N ightarrow I$

$O ightarrow D$

$P ightarrow )$

$Q ightarrow Y$

$R ightarrow L$

$S ightarrow Q$

$T ightarrow +$

$U ightarrow ``$

$V ightarrow \_$

$W ightarrow n$

$X ightarrow b$

$Y ightarrow \#$

$Z ightarrow <$

$space ightarrow \hat{ }$

Then, under this rule,

ENC("WHAT ARE YOU SAYING") = "`n6X+^XLr^#D"^QX#\I@`"

where ENC denotes encryption. You may want to confirm that the first few letters are consistent with the mapping shown above. For instance, it is indeed true that W maps to n, H maps to 6, etc.

The embedding used in the simple example is not the same embedding that was used to produce the long ciphertext given at the beginning of this project description. Your job is to recover that embedding as well as the unknown plaintext.

---

### Requirements

Your code should meet the following requirements.

1. Place all solution files in this directory (project_1). 1. You can use any of the acceptable programming languages we discussed in class. 1. Your code must read in input from a file. In other words, you must read in the ciphertext from the file ciphertext.txt. Do not hard code it as a string literal. This is essential because I will test your code on other ciphertexts. If you do not use file input to get the ciphertext then I cannot assess your work, and therefore can't grade it. 1. Whatever language you choose, the basename of your solution should be "sol". For example, if you use C call your solution `sol.c`, if you use Java then call your solution `sol.java`.

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!