-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
50 lines (47 loc) · 1.62 KB
/
Copy pathmain.cpp
File metadata and controls
50 lines (47 loc) · 1.62 KB
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
#include <iostream>
#include <string>
#include <fstream>
//#include <boost/filesystem.hpp>
using namespace std;
string EncodeRot(string ParamWord, int ParamNum)
{
string EncodedHavoc = "";
for (int i = 0; i<ParamWord.length(); i++)
{
char CharacterK = (char)ParamWord[i];
if (CharacterK >= 'a' && CharacterK <= 'm')
CharacterK += ParamNum;
else if (CharacterK >= 'n' && CharacterK <= 'z')
CharacterK -= ParamNum;
else if (CharacterK >= 'A' && CharacterK <= 'M')
CharacterK += ParamNum;
else if (CharacterK >= 'N' && CharacterK <= 'Z')
CharacterK -= ParamNum;
EncodedHavoc += CharacterK;
}
return EncodedHavoc;
}
int main()
{
string InputWord, EncodedWord;
int RotNumber;
cout << "Insert word to crypt in ROT.\n";
getline(cin, InputWord);
while (true)
{
cout << "Insert ROT Num.\n";
cin >> RotNumber;
if (RotNumber <= 25 && RotNumber >= 1)
break;
else
cout << "Number can't be larger than 13 and smaller than 1.\n";
}
ofstream OutPutLog("EncodingResult"+InputWord+ to_string(RotNumber)+".txt");
EncodedWord = EncodeRot(InputWord, RotNumber);
cout << "Input and Num: "+InputWord+" "+to_string(RotNumber)+"; "+EncodedWord+"\n";
OutPutLog << "Inserted Word: "+InputWord+".\n Encoded Word: "+EncodedWord+".\n ROT Level: "+to_string(RotNumber)+"\n";
OutPutLog.close();
//string FPath = "EncodingResult"+InputWord+ to_string(RotNumber)+".txt";
//cout << "Created Log File in "+boost::filesystem::path(FPath).string()+"\n";
return 0;
}