Professional Documents
Culture Documents
txt",ios::out ios::in ios::trunc); l: cout<<"\nEnter the choice:\n1.Encryption\n2.Decryption\n"; cin>>n; switch(n) { case 1: { cout<<"\nEnter the key value:\n"; cin>>key; cout<<"Enter data (Press $ to end input):\n"; cin>>text; i=0; while(text[i]!='$') { text[i]+=key; f<<++text[i]; i++; } cout<<"\nThe encrypted data:\n"; k=f.tellp(); i=0; f.seekg(0); while(i<k) { f>>ch; cout<<ch; i++; } break; } case 2: { cout<<"\nThe Decrypted data:\n"; f.seekg(0); i=0; while(i<k) { f>>ch; ch--; cout<<(char)(ch-key); i++; } break; } } cout<<"\nHit 1 to continue:"; cin>>r; if(r==1) goto l;
f.close(); getch(); }