I am trying to write a program that can encrypt and decrypt files using an extremely basic encryption scheme. Here's a list of what I still need:
1. Read scheme from file to be applied to input file
2. Modify input to match the scheme
3. Write output to new file
My first actual question is what is the code to read two different sets of data from one file e.i. A (3,1) on the first line, next line is B (4,6), etc.
I need to take any character from the file and assign it a coordinate to be output to a new file, and vise-versa.
Just to clarify: First set of data is the actual character, the second set being its equivalent coordinate.
here's what i got so far:
Expand|Select|Wrap|Line Numbers
- #include "stdafx.h"
- #include <iostream>
- #include <fstream>
- #include <iomanip>
- #include <string>
- using namspace std;
- int main()
- {
- char begin;
- ifstream datafile, fin;
- ofstream fout;
- string filename;
- datafile.open("sequence.dat");
- start:
- cout << "(D)ecrypt or (E)ncrypt ==> ";
- cin >> begin;
- if (begin == 'E' || begin == 'e')
- {
- cout << "Please enter the input file name: ";
- cin >> filename;
- fin.open( filename.c_str() );
- fout.open("encrypted.txt");
- fout <<
- }
- else if(begin == 'D' || begin == 'd')
- {
- cout << "Please enter the input file name: ";
- cin >> filename;
- fin.open( filename.c_str() );
- fout.open("decrypted.txt");
- fout <<
- }
- return 0;
- }