(Solved) : Histogramcpp Starting Point Statistical Attack Substitution Cipher First Find Probability Q44173066 . . .

histogram.cpp The starting point of any statistical attack on a substitution cipher is to first find the probability distribution of each of the characters that occur. We can approximate this for long inputs by analyzing the relative frequency of each letter. For example try this command. ./hist <x.clean You should see the following output. A: 0.079 B: 0.015 C: 0.025 D: 0.045 E: 0.129 F: 0.026 G: 0.020 H: 0.065 I: 0.063 J: 0.001 K: 0.007 L: 0.037 M: 0.026 N: 0.063 0: 0.077 P: 0.018 Q: 0.001 R: 0.065 S: 0.061 T: 0.096 U: 0.029 V: 0.009 W: 0.024 X: 0.001 Y: 0.017 Z: 0.001 This means that the character A is 7.9 percent of all letters in the file. E is 12.9 percent, etc. Technically the relative frequency of A is defined by _number of occurrences of A total number of letters For the file x.clean this value turns out to be 0.079. Now consider the output of this command: ./hist <y.txt It should look like this: A: 0.001 B: 0.065 C: 0.061 D: 0.096 E: 0.029 F: 0.009 G: 0.024 H: 0.001 I: 0.017 J: 0.001 K: 0.079 L: 0.015 M: 0.025 N: 0.045 O: 0.129 P: 0.026 Q: 0.020 R: 0.065 S: 0.063 T: 0.001 U: 0.007 V: 0.037 W: 0.026 X: 0.063 Y: 0.077 Z: 0.018 Observe that the frequency of K in y.txt matches the frequency of A inx.clean. This correspondence can be used to infer which characters in y.txt correspond to which characters in x.clean. This powerful attack will also work on a general substitution cipher, not just a shift cipher. Your job is to implement histogram.cpp from scratch. It is currently blank. You can use the other files as an example of how to do the IO. Encrypt and decrypt Now that your code is done, use the tools you have created to do the following. 1. Produce an encryption of the file encrypt_me.txt with key F. Call the resulting file encrypted_me.txt 2. Decrypt the file decrypt_me.txt and call the result decrypted_me.txt. You can find the key for decrypt_me.txt either by brute force, or by using your histogram function. Show transcribed image text histogram.cpp The starting point of any statistical attack on a substitution cipher is to first find the probability distribution of each of the characters that occur. We can approximate this for long inputs by analyzing the relative frequency of each letter. For example try this command. ./hist
Expert Answer
Answer to histogram.cpp The starting point of any statistical attack on a substitution cipher is to first find the probability dis…
OR