Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

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

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 10g Database Administrator Implementation And Administration

Authors: Gavin Powell, Carol McCullough Dieter

2nd Edition

1418836656, 9781418836658

More Books

Students explore these related Databases questions