Question: can someone help me write a program that decrypts data using +26 ascii code and turn it into a file. and also let user only

can someone help me write a program that decrypts data using +26 ascii code and turn it into a file. and also let user only access when the key "5" is inserted --

encrypted file using -26 ascii code:

#include  #include  #include  using namespace std; char encrypt(char c, int key) { if ('a' <= c && c <= 'z'){ if(c + key > 'z') { return c + (key - 26); } else { return c + key; } } if ('A' <= c && c <= 'Z'){ if(c + key > 'Z') { return c + (key - 26); } else { return c + key; } } return c; } int main() { string fileName; cout << "enter fileName: "; cin >> fileName; string out = "encrypted.txt"; ifstream inFile(fileName.c_str()); ofstream outFile(out.c_str()); int key; cout << "Enter key as a number from 0 to 25: "; cin >> key; char c; // read character by character from file while (inFile.get(c)) { // encode the character and output it to file c = encrypt(c, key); outFile << c; } cout << "Program completed successfully." << endl; inFile.close(); outFile.close(); }

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!