Question
This is the program I must create on C++. I did most of it such as the reading to a file and the algorithm for
This is the program I must create on C++. I did most of it such as the reading to a file and the algorithm for decrypting the ciphertext to plaintext. I'm just having trouble coming up with a for loop to implement the algorithm since I gotta read char by char from the file "Cipher.txt" so that my algorithm can switch the uppercase ciphertext letters to the lowercase plaintext letters and then somehow put that entire for loop algorithm into the section of code where I actually write to a file that has the solution to the ciphertext called "SolvedCipher.txt". The "Cipher.txt" has the following uppercase characters "MYVF VF AJNVA JQA DTFYPJ FZXJKVQE" which is suppose to read "this is david and joshua speaking" onto the "SolvedCipher.txt" file using the for loop aglorithm I constructed.
Here is the code I have come up with so far.
#include
using namespace std;
int main() { int length; int i;
char plaintext[26] = { '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' }; char ciphertext[26] = { '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' };
ifstream infile; //reading from a text file infile.open("Cipher.txt");
if (infile.fail()) { cout
if (ciphertext[25] == 'Z') //cipher algorithm { return plaintext[15]; } else if (ciphertext[24] == 'Y') { return plaintext[7]; } else if (ciphertext[23] == 'X') { return plaintext[4]; } else if (ciphertext[22] == 'W') { return plaintext[11]; } else if (ciphertext[21] == 'V') { return plaintext[8]; } else if (ciphertext[20] == 'U') { return plaintext[22]; } else if (ciphertext[19] == 'T') { return plaintext[14]; } else if (ciphertext[18] == 'S') { return plaintext[5]; } else if (ciphertext[17] == 'R') { return plaintext[16]; } else if (ciphertext[16] == 'Q') { return plaintext[13]; } else if (ciphertext[15] == 'P') { return plaintext[20]; } else if (ciphertext[14] == 'O') { return plaintext[25]; } else if (ciphertext[13] == 'N') { return plaintext[21]; } else if (ciphertext[12] == 'M') { return plaintext[19]; } else if (ciphertext[11] == 'L') { return plaintext[23]; } else if (ciphertext[10] == 'K') { return plaintext[10]; } else if (ciphertext[9] == 'J') { return plaintext[0]; } else if (ciphertext[8] == 'I') { return plaintext[1]; } else if (ciphertext[7] == 'H') { return plaintext[17]; } else if (ciphertext[6] == 'G') { return plaintext[24]; } else if (ciphertext[5] == 'F') { return plaintext[18]; } else if (ciphertext[4] == 'E') { return plaintext[6]; } else if (ciphertext[3] == 'D') { return plaintext[9]; } else if (ciphertext[2] == 'C') { return plaintext[2]; } else if (ciphertext[1] == 'B') { return plaintext[12]; } else if (ciphertext[0] == 'A') { return plaintext[3]; } else { cout
ofstream outfile; //writing to a text file outfile.open("SolvedCipher.txt"); outfile
return 0;
}
Consider the "Even-Less-Simple-Substitution" cipher. Write a program (using a programming language of your choice) that can cryptanalyze this cipher. Your program should take a ciphertext input in the form of a file, and figure out the key and output the plaintext(s) in the form of another file. This could be accomplished in a semi-automated manner (ie, a human can guide your program by providing some suggestions at runtime). You can use any resource you need (programming libraries, English dictionary, etc.) to accomplish this task. Demonstrate that your technique works for different ciphertext input files Even-less-Simple Substitution o Key is some permutation of letters Need not be a shift o For example CiphetextTCAXSEVDKMBQTZRHFMPNULG0 o Then 26! 288 possible keys
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started