2023 If you were to encrypt a file using the cipher of Exercise P9 2 the letters will | Assignment Collections
Computer Science 2023 C++ help
2023 If you were to encrypt a file using the cipher of Exercise P9 2 the letters will | Assignment Collections
If you were to encrypt a file using the cipher of Exercise P9.2, the letters will mixed up, and will appear as that you cannot decrypt it without the keyword. Also, it would seem illogical to try and guess the keyword, but someone who is trained in decryption would have no trouble breaking the cipher. The average letter frequencies of English letters are common knowledge. The most common letter E, occurs about 13% of the time.
- See Exhibit B.
- Write a program that reads as an input file and shows the letter frequencies in the file. This tool is invaluable to a code breaker. If the most frequent letters are H and K there is a high probability that they are the encryptions of E and T.
I have this code
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
void count_frequencies(string str,int list[],int size)
{
for(int i=0; i<str.length(); i++)
{
if(str[i]>=’A’ && str[i]<=’Z’)
list[str[i]-‘A’]++;
else if(str[i]>=’a’ && str[i]<=’z’)
list[str[i]-‘a’]++;
else continue;
}
}
int main()
{
ifstream infile;
string file_name;
int list[26] = { 0 };
string str;
cout <<“Enter file name to letter frequencies in the file. :”;
cin >> file_name; cout << endl;
infile.open(file_name.c_str());
if(!infile)
{
cout <<“Unable to open file . So Exiting from program :” << endl;
return 0;
}
while(!infile.eof())
{
infile >> str;
count_frequencies(str,list, 26);
}
infile.close();
cout <<“Letter t Count ” << endl;
int max = list[0];
for(int i=0; i<26; i++)
{
cout << static_cast<char> (i+’a’) <<” t ” << list[i] << endl;
if(list[i] > max ) max = list[i];
}
cout <<“Most occured letter is ” << static_cast<char> (max+’a’) << endl;
cout << “So E is Encrypted to ” << static_cast<char> (max+’a’) << endl;
//system(“pause”);
return 0;
}
but it does not work correclty.I need this ASAP
We give our students 100% satisfaction with their assignments, which is one of the most important reasons students prefer us to other helpers. Our professional group and planners have more than ten years of rich experience. The only reason is that we have successfully helped more than 100000 students with their assignments on our inception days. Our expert group has more than 2200 professionals in different topics, and that is not all; we get more than 300 jobs every day more than 90% of the assignment get the conversion for payment.