Best writers. Best papers. Let professionals take care of your academic papers

Order a similar paper and get 15% discount on your first order with us
Use the following coupon "FIRST15"
ORDER NOW

include#include#includeusingnamespacestd;voidmapitE(string,char[]);voidmapitD(string,char[])

OK. here goes. I have an assignment to write a program that take a NOTEPAD file which I have as

WEEK7.txt. 

The program asks what the name of the file is. I tell it. It takes the file and encrypts it. it then asks what you want to save it as. The program however doesn’t do the encryption. It doesn’t open the file and encrypt it and if it does I do not know how to tell it to save it as a new file name. Need help….I have attached the coding. I need help to make it work…. ATTACHMENT PREVIEW Download attachment#include<iostream>#include<fstream>#include<string>usingnamespacestd;voidmapitE(string,char[]);voidmapitD(string,char[]);voidencryptdecrypt(conststring,constchar[],int,string&);intmain(){string ende[]={“encrypt”,”decrypt”},buFer,key,newbuFer=””;char±lename[80],enmap[128],demap[128],again;inti,maplength;ofstream out;ifstream in;intchoice;do{cout<<“Enter 1 to encrypt, 2 to decrypt: “;cin>>choice;while(choice<1||choice>2){cout<<“invalid choice\n”;cout<<“Enter 1 to encrypt, 2 to decrypt: “;cin>>choice;}cout<<“Enter name of your ±le to “<<ende[choice-1]<<“: “;cin>>±lename;in.open(±lename);if(in.fail()){ cout<<“input ±le did not open please check it\n”;system(“pause”);return1;}cout<<“Enter name of your output ±le: “;cin>>±lename;out.open(±lename);cout<<“Enter your encryption key (max 128 characters): “;cin>>key;if(key.length()>128){cout<<“key too long\n”;cout<<“Enter your encryption key (max 128 characters): “;cin>>key;}maplength=key.length();if(choice==1)mapitE(key,enmap);elsemapitD(key,demap);getline(in,buFer);while(in){if(choice==1)encryptdecrypt(buFer,enmap,maplength,newbuFer);elseencryptdecrypt(buFer,demap,maplength,newbuFer);out<<newbuFer;newbuFer.erase(0);

Background image of page 1

View the Answergetline(in,bufer);}out.close();in.close();in.clear();out.clear();newbufer.erase(0);cout<<“do it again(y/n)? “;cin>>again;}while(toupper(again)==’Y’);return0;}voidencryptdecrypt(conststring bufer,constcharmap[],intlen,string& newbufer){inti=0;chart,code;For(i=0;i<bufer.length();i++){//cout<<bufer[i]<<” “<<i<<endl;iF(isalpha(bufer[i])){iF(islower(bufer[i]))code=’a’;elsecode=’A’;t=bufer[i]-code;//cout<<code<<” “<<bufer[i]<<” “<<t<<” “<<i<<endl;t=t+map[i%len];t=t%26;t=t+code;newbufer.push_back(t);}elsenewbufer.push_back(bufer[i]);}newbufer.push_back(‘\n’);}voidmapitE(string key,charmap[]){inti;For(i=0;i<key.length();i++)map[i]=key[i]-‘a’;}voidmapitD(string key,charmap[]){inti;For(i=0;i<key.length();i++)map[i]=26-(key[i]-‘a’);}

Background image of page 2
 
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"