1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <sstream>
#include <stdlib.h>
#include "Prototypes.h"
using namespace std;
/*
File encryptor does exactly what its name implies, it encrypts text files.
*/
int main()
{
string str;
MainMenu(str);
return 0;
}
void MainMenu(string &tempTxtStorage)
{
CompressDocument(tempTxtStorage);
}
void CompressDocument(string &tempTxtStorage)
{
ifstream openDoc;
string fileName;
tempTxtStorage;
vector<string> storeTextFileContents;
bool done = false;
cout << "Enter the name of the text file to be encrypted" << endl;
getline(cin, fileName);
openDoc.open(fileName.c_str());
while(getline(openDoc, tempTxtStorage))
{
ReplacingAlgorithym(tempTxtStorage);
if(openDoc.eof())
{
done = true;
cout << tempTxtStorage;
cin.get();
openDoc.close();
break;
}
}
cin.get();
}
/*
ReplacingAlgorithm()
This function Finds characters in the document and replaces them with symbols.
*/
void ReplacingAlgorithym(string &tempTxtStorage)
{
size_t pos = 0;
//string LA = "a";
//string newstr = "8";
int incrementAlpha = 0;
int incrementNum = 0;
bool ended = false;
string alphabet[26] = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};
string number[26] = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "#", "*", "(", ")", "@", "!", "%", "<", ",", "'", ">", "|", "[", "]", "{", "}"};
/*
while((pos = tempTxtStorage.find(LA, pos)) != string::npos)
{
tempTxtStorage.replace(pos, LA.length(), newstr);
pos += newstr.length();
}
*/
//trying to get program to increment the array amount so it will loop through and replace all letters
//But it will not work.
while(!ended)
{
if("z" == alphabet[incrementAlpha])
{
ended = true;
}
while((pos = tempTxtStorage.find(alphabet[incrementAlpha], pos)) != string::npos)
{
tempTxtStorage.replace(pos, alphabet[incrementAlpha].length(), number[incrementNum]);
//pos += number[incrementNum].length();
}
incrementAlpha++;
incrementNum++;
pos = 0;
}
cout << tempTxtStorage << endl;
}
void DecryptDocument()
{
}
|